flopp Posted February 8, 2012 Share Posted February 8, 2012 I have the following header navigation bar: <ul id="header_links"> <li><a href="{$link->getPageLink('index.php')}"{if $page_name == 'index'} class="active"{/if}><span>{l s='home' mod='tmheaderlinks'}</span></a></li> <li><a href="{$link->getPageLink('prices-drop.php')}"{if $page_name == 'prices-drop'} class="active"{/if}><span>{l s='specials' mod='tmheaderlinks'}</span></a></li> <li><a href="{$link->getCMSLink('1')}"{if $page_name == '?'} class="active"{/if}><span>CMS site 2</span></a></li> <li><a href="{$link->getCMSLink('2')}"{if $page_name == '?'} class="active"{/if}><span>CMS site 2</span></a></li> <li><a href="{$link->getPageLink('sitemap.php')}"{if $page_name == 'sitemap'} class="active"{/if}><span>{l s='sitemap' mod='tmheaderlinks'}</span></a></li> <li><a href="{$link->getPageLink('contact-form.php')}"{if $page_name == 'contact-form'} class="active"{/if}><span>{l s='contact' mod='tmheaderlinks'}</span></a></li> </ul> My problem is to detect the current CMS page, to add a class to it. {$page_name} only returns "cms" on all CMS pages. Is there any variable to detect the ID of the CMS-page? I have googled it, but I can't find it. Any help please? Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 13, 2012 Share Posted February 13, 2012 Hello, Use {$cms->id} 2 Link to comment Share on other sites More sharing options...
Rémy Posted February 27, 2012 Share Posted February 27, 2012 Hello, $cms->id returns nothing for me... I try this code to simply add a "selected" class : <li><a href="{$cms_page.link}" {if isset($currentCategoryId) && ($cms_page.id_cms == $currentCategoryId)}class="selected"{/if} title="{$cms_page.meta_title|escape:html:'UTF-8'}">{$cms.id}-{$cms_page.id_cms}-{$cms_page.meta_title|escape:html:'UTF-8'}</a></li> Where "{$cms.id}-{$cms_page.id_cms}-" are my witness. " $cms_page.id_cms " returns the good ID for each link, but I don't finbd how to get the "current-cms-page-id". Any idea ? Link to comment Share on other sites More sharing options...
CartExpert.net Posted February 29, 2012 Share Posted February 29, 2012 Hello, {$cms.id} is completely different to {$cms->id} So try using {$cms->id} as written in our previous post. Link to comment Share on other sites More sharing options...
CartExpert.net Posted March 5, 2012 Share Posted March 5, 2012 Hello, $cms->id returns nothing for me... I try this code to simply add a "selected" class : <li><a href="{$cms_page.link}" {if isset($currentCategoryId) && ($cms_page.id_cms == $currentCategoryId)}class="selected"{/if} title="{$cms_page.meta_title|escape:html:'UTF-8'}">{$cms.id}-{$cms_page.id_cms}-{$cms_page.meta_title|escape:html:'UTF-8'}</a></li> Where "{$cms.id}-{$cms_page.id_cms}-" are my witness. " $cms_page.id_cms " returns the good ID for each link, but I don't finbd how to get the "current-cms-page-id". Any idea ? Hello, {$cms.id} is completely different to {$cms->id} So try using {$cms->id} as written in our previous post. 1 Link to comment Share on other sites More sharing options...
Mambley Posted March 15, 2012 Share Posted March 15, 2012 Hello Cartexpert, Can you post the full code please? The <li><a ....> Thanks a lot. Link to comment Share on other sites More sharing options...
arno_64 Posted April 23, 2012 Share Posted April 23, 2012 use {debug} in your tpl file to know which variable is available 1 Link to comment Share on other sites More sharing options...
HiPresta Posted December 3, 2012 Share Posted December 3, 2012 try this one {$smarty.get.id_cms} 4 Link to comment Share on other sites More sharing options...
Rimesta7 Posted June 5, 2013 Share Posted June 5, 2013 (edited) Hello, {$cms.id} is completely different to {$cms->id} So try using {$cms->id} as written in our previous post. thanks a lot, {$cms->id} works fine with 1.5.4 Edited June 5, 2013 by Rimesta7 (see edit history) Link to comment Share on other sites More sharing options...
bbgun91 Posted June 7, 2013 Share Posted June 7, 2013 try this one {$smarty.get.id_cms} Thanks so much for this ! Actually, i'm working on the template blockcms.tpl (Prestashop v1.4.10) and what is strange is that the {debug} returns values for $cms but not for $cms_title (used in blockcms.tpl). Other strange thing, both {$cms->id} or {$cms.id} don't work for me. Only {$smarty.get.id_cms} works for me ! Thanks very much ! Link to comment Share on other sites More sharing options...
vekia Posted June 7, 2013 Share Posted June 7, 2013 (Prestashop v1.4.10) and what is strange is that the {debug} returns values smarty.get.id_cms} works for me ! Thanks very much ! thanks for that, im convinced that it will be really helpful for other forum members regards Link to comment Share on other sites More sharing options...
JaroslavB Posted July 12, 2014 Share Posted July 12, 2014 Prestashop 1.4.4.1 I used this: <li><a href="{$link->getPageLink('cms.php?id_cms=1')}"{if $smarty.get.id_cms == '1'} class="active"{/if}>{l s='cms1' mod='tmheaderlinks'}</a></li> works Link to comment Share on other sites More sharing options...
uddhava Posted October 3, 2014 Share Posted October 3, 2014 This also works // File: product.tpl // Line: 225 (depends on desired location) // This code will display a translatable link that will display a fancybox popup. // The content for this fancybox is a CMS page that is displayed as content-only. // Change the CMS ID with the correct cms page. // Change the width&height of the fancybox with javascript and the size of the cms page. <!-- 108Bits --> {if !$logged} <p><a href="{$link->getCMSLink('8')}?content_only=1" class="iframe" rel="nofollow"> {l s='Shipping Terms'}</a></p> {/if} <!-- END 108Bits --> // Add this at the end of the file (after {/if} ) <script type="text/javascript"> $('a.iframe').fancybox({ 'type' : 'iframe', 'width':500, 'height':900 }); </script> Link to comment Share on other sites More sharing options...
Klemart3D Posted November 28, 2014 Share Posted November 28, 2014 (edited) Prestashop 1.4.4.1 I used this: works Prestahop 1.6.0.9 No more working for me. I have this error : NOTICE: UNDEFINED INDEX: ID_CMS IN/THEME-FOLDER/TOOLS/SMARTY/SYSPLUGINS/SMARTY_INTERNAL_TEMPLATEBASE.PHP(157) : EVAL()'D CODE ON LINE 36 Edited November 28, 2014 by Klemart3D (see edit history) 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