0

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>

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 Prestashops forums, but not quite:

http://www.prestashop.com/forums/topic/139344-css-active-in-cms-pages/

Any help would be very much appreciated!

EDIT: I solved this myself (God knows how!) buy using this line:

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

Bear in mind you'll need to change the '/content/14-about-us' to whatever your URI is from your installation. Not the best fix, but it works.

Hope that helps someone!

4

1 回答 1

3
{if $smarty.get.id_cms == '9'} 

这也会做同样的事情。

9是厘米page id。您可以在 CMS 部分找到它。

于 2012-09-03T19:37:18.423 回答