alsheron Posted January 21, 2012 Share Posted January 21, 2012 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 More sharing options...
alsheron Posted January 22, 2012 Author Share Posted January 22, 2012 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. 1 Link to comment Share on other sites More sharing options...
tsmulugeta Posted February 11, 2012 Share Posted February 11, 2012 Your solution above didn;t work for me but this did: <li><a href="{$link->getCMSLink('35','health')}"{if {$smarty.server.REQUEST_URI} == '/35-health'} class="active"{/if}>{l s='Health Products' mod='tmheaderlinks'}</a></li> Link to comment Share on other sites More sharing options...
sting5 Posted July 11, 2012 Share Posted July 11, 2012 (edited) 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 July 11, 2012 by sting5 (see edit history) Link to comment Share on other sites More sharing options...
KonfiDD Posted February 6, 2015 Share Posted February 6, 2015 Hello ! It didn't work for me. The issue is that {$smarty.server.REQUEST_URI} or {$smarty.get.id_cms} variable doesn't upgrade when I click on an other link of blockpermanentlinks module… Any solution ? Link to comment Share on other sites More sharing options...
luca-k4b Posted November 4, 2015 Share Posted November 4, 2015 this code works for me: <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> Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now