Jump to content

sfHoverForce in TopMenu Module


Recommended Posts

Hi everyone,

 

First of all, I am using the last version of Prestashop.

 

I'm trying to modify the topmenu module to solve two problems:

1) I created two pages and when I go to these pages, the class sfHoverForce is not applied (unlike Category or CMS)

2) In my top menu, I have 4 topics (mixing categories and personnalized pages). I'd like to add a different color when the page is selected. For instance, when I go to the page My Products, I want to have "My Products" in the top menu colored in red. When I go to "My shop", I want to have "My Products" in the top menu colored in blue

 

1) For the first problem, I saw there were some explanations here:

http://www.developpez.net/forums/d1436538/php/scripts/e-commerce/prestashop/class-sfhoverforce-blocktopmenu/

and here: https://www.prestashop.com/forums/topic/393421-module-blocktopmenu-bug-sfhover-pour-lien-personalis%C3%A9/

 

Page name is "histoire" and the id page is 43 as shown in the SEO & URLs section, in the back office.

 

I tried to add this code the row 561 to blocktopmenu.php:

          case 'LNK':
                    $link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop);
                    
                    $selected = '';
                    if($this->page_name == 'histoire' && ($link[0]['id_linksmenutop'] == 43)) {
                        $selected = ' class="sfHoverForce"';
                    }
                    
                    if (count($link)) {
                        if (!isset($link[0]['label']) || ($link[0]['label'] == '')) {
                            $default_language = Configuration::get('PS_LANG_DEFAULT');
                            $link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int)Shop::getContextShopID());
                        }
                        $this->_menu .= '<li'.$selected.'><a href="'.Tools::HtmlEntitiesUTF8($link[0]['link']).'"'.(($link[0]['new_window']) ? ' onclick="return !window.open(this.href);"': '').' title="'.Tools::safeOutput($link[0]['label']).'">'.Tools::safeOutput($link[0]['label']).'</a></li>'.PHP_EOL;
                    }

However, it does not work:
- sfHoverForce is not added

- I think this part does not work but I don't know why: ($link[0]['id_linksmenutop'] == 43)

 

2) I had the idea to create four class sfHoverForce 1, 2, 3, 4 (4 entries in the topmenu) with a different color and use a if condition to add the right class to the right entry.

 

What do you think? Do you have another idea?

 

I am a begginer so please do not hesitate to over-explain!

 

Thank you in advance,

 

Pubbins

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...