Jump to content

[SOLVED] Active Header Links


Recommended Posts

I'm trying to edit the following code in tmheaderlinks.tpl in my Prestashop installation so that when "About Us" is clicked it will become "active" as do the other links:

 

<ul id="header_links">

<li><a href="{$link->getPageLink('index.php')}"{if $page_name == 'index'} class="active"{/if}>{l s='home' mod='tmheaderlinks'}</a></li>

<li><a href="{$link->getPageLink('prices-drop.php')}"{if $page_name == 'prices-drop'} class="active"{/if}>{l s='specials' mod='tmheaderlinks'}</a></li>

<li><a href="{$link->getPageLink('contact-form.php')}"{if $page_name == 'contact-form'} class="active"{/if}>{l s='contact' mod='tmheaderlinks'}</a></li>

<li><a href="{$link->getPageLink('cms.php?id_cms=14')}"{if $page_name == 'about-us'} class="active"{/if}>{l s='About Us' mod='tmheaderlinks'}</a></li>

</ul>

<!-- /Block permanent links module -->

 

The variable $page_name in Prestashop is set using the id of the page, and because the About Us page is sourced from the CMS feature of Prestashop, the id is set to 'cms' which isn't very useful because it would make the link active for all pages displayed from the CMS.

 

Is there a variable I can use that can replace the $page_name variable for the About Us entry? Or is there a way of testing for the Page Title instead of name and then setting the class as active?

 

Or can I assign the $page_name variable to a specific value (about-us) for the About Us page in the CMS?

 

I've seen a couple of solutions that came close on the forum, but not quite:

 

http://www.prestasho...e-in-cms-pages/

 

Any help would be very much appreciated!

Link to comment
Share on other sites

OK, I solved this by using the following format for links:

 

<li><a href="{$link->getPageLink('cms.php?id_cms=29')}"{if {$smarty.server.REQUEST_URI} == '/content/29-about-us'} class="active"{/if}>{l s='about us' mod='tmheaderlinks'}</a></li>

 

Hope that helps someone. :)

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 5 months later...

None of the above helped and I've spent days for trying to solve this. If You didn't succeed with any of the above, try this:

 

<li id="header_link_about_us"><a href="{$link->getPageLink('cms.php?id_cms=4', true)}" title="{l s='About us' mod='blockpermanentlinks'}" {if $smarty.get.id_cms
== '4'} class="active"{/if}>{l s='About us' mod='blockpermanentlinks'}</a></li>

 

 

NOTE: this code is used when trying to edit the permanentlinks block file called "blockpermanentlinks-header.tpl", not the "tmheaderlinks" mod category of any kind - I hope admin will correct me if I made mistakes by explaining this.

Edited by sting5 (see edit history)
Link to comment
Share on other sites

  • 2 years later...
  • 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...