Anca Amalia Posted April 18, 2015 Share Posted April 18, 2015 (edited) Hi, I need to add a link to a subcategory of one of the category of the mail menu. I mean I have the category Publicity Items and as subcategories of it Vehicles Items, Religious Commemorations, ...., Others Items and I need to add an external link to this last subcategory. I´ve tried changing the code from module/blockcategories/category-tree-branch.tpl with <a href={if $node.id == 218} http://www.google.es {else}{$node.link|escape:html:'UTF-8'}{/if} {if isset($currentCategoryId) && $node.id == $currentCategoryId}class="selected"{/if} title="{$node.desc|strip_tags|trim|truncate:255:'...'|escape:'html':'UTF-8'}">{$node.name|escape:'html':'UTF-8'}</a> but nothing happens... Thanks. Edited April 29, 2015 by Anca Amalia (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted April 19, 2015 Share Posted April 19, 2015 Hi Anca, The file is normally overridden in the theme dependent folder, so try to edit it here: themes/<your theme folder>/modules/blockcategories/category-tree-branch.tpl At least you should see some action :-) (Also, temporarily set force compilation to YES and smarty cache = OFF in advanced parameters->Performance, otherwise the old/cached version keeps showing. Don't forget to put these option back to the old values after you see it's working, otherwise your site will be slooooow) My 2 cents, pascal Link to comment Share on other sites More sharing options...
Anca Amalia Posted April 19, 2015 Author Share Posted April 19, 2015 Hi Pascal, Thanks for the replay. That`s the file I've changed and I've changed the other one too just in case, but,no, it is not working...Nothing happens..... I also forced complilation, smarty chache off, no cache and also delete history... and nothing Any idea? Link to comment Share on other sites More sharing options...
PascalVG Posted April 21, 2015 Share Posted April 21, 2015 Hmm, can you add some nonsense text in front of the name, just to see if the file compiles? <a href={if $node.id == 218} http://www.google.es {else}{$node.link|escape:html:'UTF-8'}{/if} {if isset($currentCategoryId) && $node.id == $currentCategoryId}class="selected"{/if} title="{$node.desc|strip_tags|trim|truncate:255:'...'|escape:'html':'UTF-8'}">AAAAAA{$node.name|escape:'html':'UTF-8'}</a> Link to comment Share on other sites More sharing options...
diana13 Posted April 21, 2015 Share Posted April 21, 2015 (edited) It works for the left menu. But for topmenu is there a way to add a link to, let's say for node=2 ? Edited April 21, 2015 by diana13 (see edit history) Link to comment Share on other sites More sharing options...
Anca Amalia Posted April 21, 2015 Author Share Posted April 21, 2015 Hi Pascal, Thanks for the replay. Hmmmm you are wright!!!! Ok, now I've deleted all cache and try it again. As Diana13 said is working for the left menu but not for topmenu... Link to comment Share on other sites More sharing options...
PascalVG Posted April 26, 2015 Share Posted April 26, 2015 To add a fixed link to the top menu, you can go to the configure screen of the top horizontal menu and then at the bottom "add a new link" The path you can just find by going to the page you want to link to and copy the URL. Past this in the link field. Hope that's what you needed. If not, please elaborate. pascal. Link to comment Share on other sites More sharing options...
Anca Amalia Posted April 27, 2015 Author Share Posted April 27, 2015 Hi Pascal, I now you can add the link to a category from the top horizontal menu. my inquiery is how you add the link to a subcategory of one of the category of the top horizontal menu. I mean, for example you have as a category of the top horizontal menu Publicity Items and one of it subcategory is More Items. Well with the code modification made, the link is applied to this subcategory More Items in the Vertical Menu, but no link is applied in the top horizontal menu. Thanks again for your colaboration... Link to comment Share on other sites More sharing options...
PascalVG Posted April 29, 2015 Share Posted April 29, 2015 Ah, sorry, So you have a special sub category in the top horizontal menu, (For diana, category with 218) but want to have the link changed into a fixed external link right? (See image) Let me have a look at that. Patience... pascal. Link to comment Share on other sites More sharing options...
PascalVG Posted April 29, 2015 Share Posted April 29, 2015 OK, Edit file: (make backup!!!) modules/blocktopmenu/blocktopmenu.php in function: private function generateCategoriesMenu($categories, $is_children = 0) add red code: private function generateCategoriesMenu($categories, $is_children = 0) { $html = ''; foreach ($categories as $key => $category) { if ($category['level_depth'] > 1) { $cat = new Category($category['id_category']); if ((int)$cat->id_category == 5) // change 5 to your category id $link = "http://google.com/"; // change to your own URL else $link = Tools::HtmlEntitiesUTF8($cat->getLink()); } else $link = $this->context->link->getPageLink('index'); Then, make sure in advanced parameters ->Performance Your force compilation is ON, and smarty Cache is OFF (and press "clear cache" in top right of this page) Then load any page with top menu, and see if it works. Hope this is what you needed, pascal Link to comment Share on other sites More sharing options...
Anca Amalia Posted April 29, 2015 Author Share Posted April 29, 2015 Hi Pascal, Thanks a lot!!! problem solved!!!! Anca Link to comment Share on other sites More sharing options...
PascalVG Posted April 30, 2015 Share Posted April 30, 2015 Good to hear :-) Happy selling, pascal Link to comment Share on other sites More sharing options...
danconvil Posted October 1, 2015 Share Posted October 1, 2015 Hi, I need to add an external link on blockcategories in the left column of my store. Thank Link to comment Share on other sites More sharing options...
Johnny2525 Posted November 3, 2016 Share Posted November 3, 2016 Cant find this (private function generateCategoriesMenu($categories, $is_children = 0)in my files. I want to add a subcategory link that links to a manufacturer page on my site. CATEGORIES Fine Watches *Rolex (I want these 2 subcategories to be links to my manufacturer page with the corresponding products) *Panerai Please Help Thanks Johnny Link to comment Share on other sites More sharing options...
rocky Posted November 3, 2016 Share Posted November 3, 2016 It's on line 593 (in PrestaShop v1.6.1.8) of modules/blocktopmenu/blocktopmenu.php: protected function generateCategoriesMenu($categories, $is_children = 0) Link to comment Share on other sites More sharing options...
Johnny2525 Posted November 9, 2016 Share Posted November 9, 2016 Perfect! Thank You Link to comment Share on other sites More sharing options...
bogdanpatr Posted February 10, 2017 Share Posted February 10, 2017 (edited) Hello Pascal, i've done exactly like u've explained above with no success. I replaced categories number with several and no luck. my blocktopmenu.php looks like this: protected function generateCategoriesMenu($categories, $is_children = 0) { $html = ''; foreach ($categories as $key => $category) { if ($category['level_depth'] > 1) { $cat = new Category($category['id_category']); if ((int)$cat->id_category == 2) $link = "anpc.gov.ro"; // change to your own URL $link = Tools::HtmlEntitiesUTF8($cat->getLink()); } else { $link = $this->context->link->getPageLink('index'); } I'm rather new to Prestashop, and don't have that much PhP experience... What i want to do is this: Have a menu: Terms and conditions with several items: (legal advice, refund policy, etc). Some of the "items" will be direct external links to state authorities, so i can't go to another CMS page and from there to the external URL. Is it even possible? Thank you in advance, Edited February 10, 2017 by bogdanpatr (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