helpmeplease Posted July 5, 2010 Share Posted July 5, 2010 Hi,I've set up a html menu on my site using the addstuff module. This works fine, but I'd like to be able to mark a page as selected when its been clicked. When I normally build a site I would use a body id tag, for example body id="homepage" and then in the CSS I'd have the page selected using the body id tag in the head content of the html.Is this possible in Prestashop? - I've looked at the source code on each page but I can't find a way of doing this.If this isn't possible my second question is, if it's possible to create a menu on the left hand side that includes both category and cms links - and to choose the order and which items are displayed?Sorry for being greedy with two questions!Hope someone can help or point me in the right direction - thanks in advanceBest wishesBrian Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 I'm not aware of any module that lets you mix CMS and category links in the left column.PrestaShop puts the page name as the ID of the page in header.tpl in your theme's directory, so you can use body#new-products for new-products.php, body#contact-form for contact-form.php, etc. If you need to target specific CMS pages, you'll need to modify header.tpl and change line 40 from: <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}> to: <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}{if $page_name == 'cms'} class="cms{$smarty.get.id_cms}"{/if}> so that you can use body.cms1, body.cms2, etc. Link to comment Share on other sites More sharing options...
helpmeplease Posted July 6, 2010 Author Share Posted July 6, 2010 Hi Rocky,That worked a treat - Thank You!I must have spent over 6 hours yesterday trying to work it out for myself with no successSorry for the further question - (but I must ask!)Is there a way of doing this same procedure with the category pages and individual product pages?I'd like to be able to create a custom menu that highlights options from the cms, category and product pagesIf there's not, no worries - and thanks again for your helpBrian Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 You could expand on my code to include categories and products like this: body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}{if $page_name == 'cms'} class="cms{$smarty.get.id_cms}"{elseif $page_name == 'category'} class="category{$smarty.get.id_category}"{elseif $page_name == 'product'} class="product{$smarty.get.id_product}"{/if}> Link to comment Share on other sites More sharing options...
helpmeplease Posted July 6, 2010 Author Share Posted July 6, 2010 Fantastic - it works perfectly!Thanks again for your helpBest wishesBrian Link to comment Share on other sites More sharing options...
rocky Posted July 6, 2010 Share Posted July 6, 2010 If your issue is resolved, please edit your first post and add [sOLVED] to the front of the title. Link to comment Share on other sites More sharing options...
webmc Posted September 8, 2010 Share Posted September 8, 2010 This is very good, thanks.Is there a way that Prestashop can tell the level of subcategories?ie if it was a sub category of a subcategory?{elseif $page_name == 'category'}or if you can give a page name to a specific category? Link to comment Share on other sites More sharing options...
rocky Posted September 8, 2010 Share Posted September 8, 2010 Yes, you can use the following code in category.tpl to get the depth of the category: {$category->level_depth} Link to comment Share on other sites More sharing options...
Ron morales Posted December 4, 2012 Share Posted December 4, 2012 in this module blocktopmenu i need the class active i test but not fuction case 'LNK': $selected = ($link->getPageLink == $page_name ) ? ' class="sfHover"' : ''; $link = MenuTopLinks::get((int)$id, (int)$id_lang, (int)$id_shop); if (count($link)) { if (!isset($link[0]['label']) || ($link[0]['label'] == '')) { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int)Shop::getContextShopID()); } $this->_menu .= '<li'.$selected.' ><a href="'.$link[0]['link'].'"'.(($link[0]['new_window']) ? ' target="_blank"': '').'>'.$link[0]['label'].'</a></li>'.PHP_EOL; } break; 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