Jump to content

Change blocktopmenu current links


Recommended Posts

Hello Everyone,

I would like to change the colors of the navigation bar to red on the hover and the current link. I changed the hover it works fine. How do you change the color, for example when you click about us page it turns red, while the other links are blue.

 

I tried to edit the superfish_modified.css in the modules/topblockmenu/css and i have written this code:

 

.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {

background: #fe0003;

 

}

 

This works for the hover, but once clicked the page I am on doesnt change color for link.

 

Any help is greatly appreciated, I just drunk 12 cups of coffee and still haven't figured this out.

Link to comment
Share on other sites

Aw, cm on, don't give up just yet. :)

There is no regular or uncommon way, .current is the exact same as .sfhoverforce since it's just a class.

 

You can't do it by css and html only, if you really want to change the current class. You will have to mess with php.

 

targeting .shHoverForce works for me. Again, you must be on 1.5.3.1

Link to comment
Share on other sites

Maybe this could help you to get the job done. With version 1.5.3.1 I built a custom horizontal top menu for some of the static pages in the shop. In my theme I added to the header template "header.tpl" the following code:

 

<div id="header_menu_balk">
<ul>
  <li class="item"><a {if substr_count($smarty.server.REQUEST_URI, "prices-drop" )}id="current_headermenuitem"{/if} href="{$link->getPageLink('prices-drop')}" title="{l s='Price drop'}">{l s='Price drop'}</a></li>
  <li class="item"><a {if substr_count($smarty.server.REQUEST_URI, "new-products" )}id="current_headermenuitem"{/if} href="{$link->getPageLink('new-products')}" title="{l s='New products'}">{l s='New products'}</a></li>
  <li class="item"><a {if substr_count($smarty.server.REQUEST_URI, "best-sales" )}id="current_headermenuitem"{/if} href="{$link->getPageLink('best-sales')}" title="{l s='Top sellers'}">{l s='Top sellers'}</a></li>
  <li class="item"><a {if substr_count($smarty.server.REQUEST_URI, "stores" )}id="current_headermenuitem"{/if} href="{$link->getPageLink('stores')}" title="{l s='Our stores'}">{l s='Our stores'}</a></li>
  <li class="item"><a {if substr_count($smarty.server.REQUEST_URI, "contact-us" )}id="current_headermenuitem"{/if} href="{$link->getPageLink('contact')}" title="{l s='Contact'}">{l s='Contact'}</a></li>
  </ul>
</div>

 

To change the list items for the current state I added the following to my custom stylesheet:

 

#header_menu_balk  li > a {
color: #ffffff;
}
#header_menu_balk  li > #current_headermenuitem{
color: #59bde8;
}
#header_menu_balk  li > a:hover {
color: #59bde8;
text-decoration: none;
}

  • Like 1
Link to comment
Share on other sites

Multiple solutions:

 

1. you add it to the header template itself enclosed in the smarty tag {literal}{/literal} to prevent the {} brackets in the styles from generating Smarty errors.

 

{literal}
<style>
#header_menu_balk  li > a {
color: #ffffff;
}
#header_menu_balk  li > #current_headermenuitem{
color: #59bde8;
}
#header_menu_balk  li > a:hover {
color: #59bde8;
text-decoration: none;
}
</style>
{/literal}

 

2. You add it to one of the style sheets that are already loaded by your theme.

 

3. You add a new custom stylesheet to your header.tpl.

Make sure you load this custom stylesheet right before the closing </head> tag to prevent other styles from overruling your customisations.

<link href="/themes/your_theme/css/your_custom_stylesheet.css" rel="stylesheet" type="text/css" media="all" />

 

Hope this helps. Have a great weekend.

  • Like 1
Link to comment
Share on other sites

  • 6 months later...

Hi! It works with category but not for home.. do you have a nice way to edit the php file to add class "sfHoverForce (for example)" on the li selected?

 

personnaly, I trought editing this part of code:

case 'SHOP':
 $selected = ($this->page_name == 'index' && ($this->context->shop->id == $id)) ? ' class="sfHover"' : '';

 

while doing:

case 'SHOP':
                   $selected = ($this->page_name == 'index' && ($this->context->shop->id == $id)) ? ' class="sfHover sfHoverForce"' : '';

..

 

no way! It doesnt work.. I was expecting the "sfHoverForce" class will be added on the line selected. Normally, this could have effect to add that class when the Case condition is valid.. but none!

 

any better idea? or tell me what have I forget to do...

 

Tks so much!

Link to comment
Share on other sites

  • 8 months 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...