tornado1979 Posted November 6, 2013 Share Posted November 6, 2013 (edited) hello, i need to create a new menu category on the ,'top horizontal menu' ,for my website, for example: (parent category) THE COMPANY (1st child) About us (2nd child) Partners (3rd child) Gallery this seems that it cannot be done from the configuration of the module (in the administration area). is there a way to create these links as i show above? my third child is a link of a gallery module, so can i put the link on a CMS page ? thank you. Edited November 7, 2013 by vekia (see edit history) 1 Link to comment Share on other sites More sharing options...
vekia Posted November 6, 2013 Share Posted November 6, 2013 hello you can create: cms category: The Company cms pages: About us, Parners, Gallery then in top horizontal menu add The Company category, it will appear as a separate item with dropdown list with pages attached to this category 6 Link to comment Share on other sites More sharing options...
tornado1979 Posted November 6, 2013 Author Share Posted November 6, 2013 hello Vekia, you are always here to help, i can count on you. so, ok for the 'the company' and 'partners' i can create them as cms page. what about the 'photos', it is just a link to the gallery module , like : index.php?fc=module&module=azgallery&controller=gallery Can i write something inside the 'Page content' and redirect me to the image gallery ? Link to comment Share on other sites More sharing options...
vekia Posted November 6, 2013 Share Posted November 6, 2013 If i were you i will create CMS page then in blocktopmenu.php file instead of: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } use this: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } } if ($cms->id==4) - this is if condition with ID of gallery cms page. instead of "URL_TO_GALLERY" use url to your gallery page 5 Link to comment Share on other sites More sharing options...
tornado1979 Posted November 7, 2013 Author Share Posted November 7, 2013 hello Vekia, i got it. when you say id == 4 you actually mean the id of the gallery cms (i will create a cms which i will name it gallery.) and on the URL_TO_GALLERY i am going to write the link to load the gallery. it is a clever trick, i will try it and i will let you know asap. thnks. Link to comment Share on other sites More sharing options...
vekia Posted November 7, 2013 Share Posted November 7, 2013 that's right, don't forget to let me know if everything will work well, or if not too Link to comment Share on other sites More sharing options...
tornado1979 Posted November 7, 2013 Author Share Posted November 7, 2013 i test it and, it works! well done for once more vekia. Link to comment Share on other sites More sharing options...
vekia Posted November 7, 2013 Share Posted November 7, 2013 yeah, nice i marked this thread as [solved] if you need any additional asistance, im here best regards Link to comment Share on other sites More sharing options...
elisa1212 Posted November 29, 2013 Share Posted November 29, 2013 hello, i need to add a link in the top horizontal menu. In my menu there are all my products categories and they show the related subcategories. Now in the list of subcategories of the category 2 i would like to add a link to a cms page. is there a way to create this link? thanks Link to comment Share on other sites More sharing options...
vekia Posted November 30, 2013 Share Posted November 30, 2013 hello, i need to add a link in the top horizontal menu. In my menu there are all my products categories and they show the related subcategories. Now in the list of subcategories of the category 2 i would like to add a link to a cms page. is there a way to create this link? thanks what you mean by category 2 ? it's a category ID, or what? Link to comment Share on other sites More sharing options...
albigin Posted November 30, 2013 Share Posted November 30, 2013 Hi vekia, please what do you mean exactly when you say: "then in top horizontal menu add The Company category" ? How do you achieve that? I've been trying this way: - created category - created pages in that category - saved but nothing appears in my top menu (using default theme on prestashop 1.5.6.1) Thx Link to comment Share on other sites More sharing options...
Paulito Posted December 1, 2013 Share Posted December 1, 2013 Good morning The original question was about adding CMS pages to the horizontal menu, like this: http://screencast.com/t/Pd1hSr4ob5nK Are you looking to achieve something similar? Paul Link to comment Share on other sites More sharing options...
albigin Posted December 1, 2013 Share Posted December 1, 2013 Hi Paulito, and thank you for you reply. Yes, I'm trying to have items on the top horizontal menu. For the moment I only have there a Home tag, I wish I could add something like The Company with subcategories, as per the image you linked. I still can't find out how to do that! Any help would be appreciated. Link to comment Share on other sites More sharing options...
Paulito Posted December 1, 2013 Share Posted December 1, 2013 Good morning Using PS 1.5.5 default theme This is showing you how to add CMS pages to the default Horizontal menu. You can, of course add many links by repeating #6 OK try this: 1. http://screencast.com/t/geziRlxn 2. http://screencast.com/t/Pkj7wQwv 3. http://screencast.com/t/nfPhUj5PR 4. http://screencast.com/t/pepOxY0t 5. http://screencast.com/t/XZh4q7lmqRm 6. Go to: Back office > Modules > Modules > Front office features > scroll down to Top horizontal menu > Configure http://screencast.com/t/a9qFcoxEY 7. Result http://screencast.com/t/MNKhCnLzMm Hope this helps Paul PS. Don't forget to use the same language 1 Link to comment Share on other sites More sharing options...
tornado1979 Posted December 1, 2013 Author Share Posted December 1, 2013 hello albigin, Paulito gave you a complete and in detail solution about how to create the CmsMenu, i hope it is clear to you now. As for the second part of your question , 'how to add a link to a gallery under that menu': let me ask you something, can you code? are you familiar with the presta architecure? because only with custom code can it be done, there is no ready configuration for that. 1st. You add another one 'child cms page' and call it Gallery, under your cms menu. 2nd. You open the php file that controls the top menu, blocktopmenu.php 3rd. You should do the Vekia's proposal, and you will have a link that redirects to a gallery: If i were you i will create CMS page then in blocktopmenu.php file instead of: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } use this: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : '';if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>';} else {$this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } } if ($cms->id==4) - this is if condition with ID of gallery cms page. instead of "URL_TO_GALLERY" use url to your gallery page 4th kindly take a look on my conversation with Vekia in order to copmletely understand the solution. Link to comment Share on other sites More sharing options...
stottycabanas Posted December 1, 2013 Share Posted December 1, 2013 (edited) Just to add - Paul's instructions are perfect for CMS pages, but if you want to click on the dropdown entry to go to something other than a CMS page (e.g. the photo gallery in the original post), you'll need to use the code change provided by Vekia in post #4. Cheers, Dave Hey tornado, great minds think alike! Edited December 1, 2013 by stottycabanas (see edit history) Link to comment Share on other sites More sharing options...
albigin Posted December 1, 2013 Share Posted December 1, 2013 dear Paul, stottycabanas and tornado1979 sorry for the delay in replying to you kind posts: I was celebrating my stepmother's birthday (I live in Italy and presently it is 16:12 hours). What Paul sent me is very, very clear: I was missing step #6. I followed the instrucions and now the top menu works like a charm. Thank you very, very much for sharing your knowledge with the community, I hope I could help you as kindly as you did with me Link to comment Share on other sites More sharing options...
albigin Posted December 1, 2013 Share Posted December 1, 2013 tornado, I didn't ask for the explanation you gave about adding a link to a gallery but I do appreciate your help. It could be useful in the future Bye for now. Link to comment Share on other sites More sharing options...
elisa1212 Posted December 2, 2013 Share Posted December 2, 2013 Hi Vekia, sorry for the delay. Yes, category 2 is the category ID. In the drop down list of the subcategories of this I would to add the link of cms page. How can I do? Link to comment Share on other sites More sharing options...
khaledsaied Posted December 15, 2013 Share Posted December 15, 2013 Hi I have achieved to add cms categories with subpages/subcategories to the top horizontal menu. But I wan't to add productcategories(not cms categories) as submenu to a cms page or just having the productcategories being gathered under different menuitems from home as it is now. How can I achieve that? see below images:One image shows what I wan't and the other shows that currently categories are only bound to home. Link to comment Share on other sites More sharing options...
yapp12 Posted January 31, 2014 Share Posted January 31, 2014 How to create categories and subcategories with the module Horizontal menu advanced in the admin ? Screenshot or tutorial ? Link to comment Share on other sites More sharing options...
vekia Posted January 31, 2014 Share Posted January 31, 2014 Horizontal menu advanced you mean default menu? or some external solution? in the admin ? i think that there is no module for create menu in back office, because to create menu items in BO, you have to create controllers to handle these menu items. Link to comment Share on other sites More sharing options...
Ismael Arguedas Posted March 19, 2014 Share Posted March 19, 2014 (edited) If i were you i will create CMS page then in blocktopmenu.php file instead of: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } use this: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } } if ($cms->id==4) - this is if condition with ID of gallery cms page. instead of "URL_TO_GALLERY" use url to your gallery page Hello Vekia, Thanks for your solution, really works. How can I add more than one CMS links? I had got add one link with your solution, but when I copy the code twice and insert other ID and link, I get a menú with categories CMS duplicate. Also I tested with other changes and happens the same. Do you can Help me please? Edited March 19, 2014 by Maelux (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted March 20, 2014 Share Posted March 20, 2014 you can add additional if conditions in elseif clause, take a look: if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } elseif ($cms->id==7) { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_ANOTHER_PAGE>'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } Link to comment Share on other sites More sharing options...
Ismael Arguedas Posted March 20, 2014 Share Posted March 20, 2014 (edited) you can add additional if conditions in elseif clause, take a look: if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } elseif ($cms->id==7) { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_ANOTHER_PAGE>'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } Thank you very much Vekia, works perfectly¡ Edited March 20, 2014 by Maelux (see edit history) Link to comment Share on other sites More sharing options...
[email protected] Posted April 22, 2014 Share Posted April 22, 2014 Hello, in prestashop 1.6 its defferent: find and open "root"/modules/blocktopmenu/blocktopmenu.php find if ($depth > 3) (in my file - line 515) rewrite if ($depth > 1) save See www.skycom.sk (my first post here) Link to comment Share on other sites More sharing options...
vekia Posted April 22, 2014 Share Posted April 22, 2014 (my first post here) your website doesnt work Link to comment Share on other sites More sharing options...
[email protected] Posted April 22, 2014 Share Posted April 22, 2014 (edited) Oh i see now, all my pages on hosting using some mysql server. that is technical error on server.. will wait 23:33 - working :-) Edited April 22, 2014 by [email protected] (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted April 23, 2014 Share Posted April 23, 2014 ok it works now but to be honest i don't see differencies between original code website, and your website with changed code Link to comment Share on other sites More sharing options...
[email protected] Posted April 23, 2014 Share Posted April 23, 2014 You are right, something goes wrong, Iam working on it.. Link to comment Share on other sites More sharing options...
ericleonardocunha Posted May 1, 2014 Share Posted May 1, 2014 Hello, please guys, How can I change the time top menu takes to show subcategories when pass mouse over? In Prestashop 1.6, top menu is very slow showing up on hover. I would like it open immediate, no delay. I'd tried find in CSS but nothing found. The only one I'd found is delay time for it desapear. But I want reduct delay for OPEN. Thanks in advance! Link to comment Share on other sites More sharing options...
ericleonardocunha Posted May 1, 2014 Share Posted May 1, 2014 It's SOLVED. Changed the speed of Top Menu!!!! So it opens immediately on mouse hover. Just edit the file: /Themes/Default-bootstrap/js/modules/blocktopmenu/js/hoverIntent.js Put "interval": 0 // default configuration values var cfg = { interval: 000, sensitivity: 7, timeout: 0 }; Link to comment Share on other sites More sharing options...
Jeff Chan Posted May 11, 2014 Share Posted May 11, 2014 Thanks for sharing! its work fine! Can I remove the default link when click on the CMS on the top menu because I dont want to display the list of that CMS. Also, if the list displayed the "Gallery" method on the list will not working and only display a blank Gallery page! Thank for advice!! Link to comment Share on other sites More sharing options...
Crezco Posted July 8, 2014 Share Posted July 8, 2014 May I reopen this topic? I'm working on Persta 1.6, and would like to make an itemon the top menu with 3 sub items on it. Such sub items are external links. I've created the 3 external links on the module back office, but I don't know how to tie them in a submenu. thanks everybody, Link to comment Share on other sites More sharing options...
vekia Posted July 9, 2014 Share Posted July 9, 2014 this feature is not available in prestashop, unfortunately. the only one thing you can do is a main menu item with custom link that you created Link to comment Share on other sites More sharing options...
kbytin Posted July 27, 2014 Share Posted July 27, 2014 Hi, is it possiable to add link to category thumb in top menu, link to the same category of the thumb. thx Link to comment Share on other sites More sharing options...
wakabayashi Posted August 2, 2014 Share Posted August 2, 2014 (edited) If i were you i will create CMS page then in blocktopmenu.php file instead of: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } use this: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } } if ($cms->id==4) - this is if condition with ID of gallery cms page. instead of "URL_TO_GALLERY" use url to your gallery page Thx Vekia for this nice little change. Its working perfect. This solution is also working for mulitshops, right? Edited August 2, 2014 by wakabayashi (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 2, 2014 Share Posted August 2, 2014 yes it will also work with multishop what you exactly expect? Link to comment Share on other sites More sharing options...
wakabayashi Posted August 2, 2014 Share Posted August 2, 2014 I was just thinking if I use same cms page on 2 stores, but don't want the same link for both pages. But it's no real problem. Since its easy to just make 2 different cms pages Link to comment Share on other sites More sharing options...
vekia Posted August 3, 2014 Share Posted August 3, 2014 you can also add additional IF condition to check what shop customer view :-) then it will appear (code) only on selected cms pages and shop Link to comment Share on other sites More sharing options...
wakabayashi Posted August 3, 2014 Share Posted August 3, 2014 Yeah I thought so, but I dont know how. I tried: if ($cat->id== 5 and $id_shop==1) But this is not working. Do you know how its working? Anyway thank you very much for your effort. It's amazing what you do for community Link to comment Share on other sites More sharing options...
vekia Posted August 4, 2014 Share Posted August 4, 2014 try to deal with $cart->id_shop variable :-) 1 Link to comment Share on other sites More sharing options...
computekiruna Posted October 27, 2014 Share Posted October 27, 2014 If i were you i will create CMS page then in blocktopmenu.php file instead of: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } use this: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } } if ($cms->id==4) - this is if condition with ID of gallery cms page. instead of "URL_TO_GALLERY" use url to your gallery page I tried and it did not work. Should we do something more? Thanksss!!! Link to comment Share on other sites More sharing options...
neonspoke Posted January 30, 2015 Share Posted January 30, 2015 If i were you i will create CMS page then in blocktopmenu.php file instead of: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } use this: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } } if ($cms->id==4) - this is if condition with ID of gallery cms page. instead of "URL_TO_GALLERY" use url to your gallery page This seems like a great workaround, but it's not working for me: default-bootstrap, 1.6. I'm trying to add "manufacturers pages" as submenu links to a CMS page. For example: /index.php?id_cms=4&controller=cms ----/index.php?id_manufacturer=20&controller=manufacturer -----/index.php?id_manufacturer=21&controller=manufacturer -----/index.php?id_manufacturer=22&controller=manufacturer Thanks V, you're the only reason I can do Prestashop! GT Link to comment Share on other sites More sharing options...
yrejk Posted March 18, 2015 Share Posted March 18, 2015 Another solution (if you don't want add an hardcoded ID in your code) is : if (strpos($cms->meta_description, 'REDIRECT:') !== False) { $this->_menu .= '<a href="'.str_replace("REDIRECT:", "", $cms->meta_description).'">'.$cms->meta_title.'</a>'; } else { $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; } That allow you to set: "REDIRECT:/myblog" in meta description of a cms page... So in your menu, you can add this cms page, which one will be just a link to a external page... You can see here an example : https://www.perfecthealthsolutions.eu in the "Informations +" Menu PS : I do it in meta_description, but you can do it in your favorite field. But perso, I prefere to keep the $cms->content() with a simple link to allow a fallback if I update the module and forget to cherry pick this change ! 1 Link to comment Share on other sites More sharing options...
oliver_33 Posted May 14, 2015 Share Posted May 14, 2015 I tried to do this but it is something wrong. I created the category and the pages cms and changed the code but does not work in the topmenu. When checking the link it appears only in the child page and weirder is that the link is there even after I delete the code in menutop what is happening here??? Link to comment Share on other sites More sharing options...
oliver_33 Posted May 14, 2015 Share Posted May 14, 2015 I tried to do this but it is something wrong. I created the category and the pages cms and changed the code but does not work in the topmenu. When checking the link it appears only in the child page and weirder is that the link is there even after I delete the code in menutop what is happening here??? Ok, I need to update de topmenu after code changings I dont no why but only the yrejk code work for me Link to comment Share on other sites More sharing options...
babak1410 Posted June 5, 2015 Share Posted June 5, 2015 Another solution (if you don't want add an hardcoded ID in your code) is : if (strpos($cms->meta_description, 'REDIRECT:') !== False) { $this->_menu .= '<a href="'.str_replace("REDIRECT:", "", $cms->meta_description).'">'.$cms->meta_title.'</a>'; } else { $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; } That allow you to set: "REDIRECT:/myblog" in meta description of a cms page... So in your menu, you can add this cms page, which one will be just a link to a external page... You can see here an example : https://www.perfecthealthsolutions.eu in the "Informations +" Menu PS : I do it in meta_description, but you can do it in your favorite field. But perso, I prefere to keep the $cms->content() with a simple link to allow a fallback if I update the module and forget to cherry pick this change ! hi. Can you explain more of? In one file, and where do you use it? REDIRECT and link, rather than what to do? Should they instead use vekia code? Thank you. Link to comment Share on other sites More sharing options...
igi008 Posted July 1, 2015 Share Posted July 1, 2015 (edited) hi. Can you explain more of? In one file, and where do you use it? REDIRECT and link, rather than what to do? Should they instead use vekia code? Thank you. You need change file: modules/blocktopmenu/blocktopmenu.php foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; if (strpos($cms->meta_description, 'REDIRECT:') !== False) { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.str_replace("REDIRECT:", "", $cms->meta_description).'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } } Don't forget, if you need deactivate top category item link of CMS menu to list of CMS articles, you need change too this section (only remove code inside href): case 'CMS_CAT': $category = new CMSCategory((int)$id, (int)$id_lang); if (count($category)) { $this->_menu .= '<li><a href="" title="'.$category->name.'">'.$category->name.'</a>'; $this->getCMSMenuItems($category->id); $this->_menu .= '</li>'.PHP_EOL; } break; Edited July 1, 2015 by igi008 (see edit history) Link to comment Share on other sites More sharing options...
phingko Posted July 3, 2015 Share Posted July 3, 2015 Hi, I tried vekia's code but instead my whole website just went blank. May I know the url what kind of format that I need to use? I tried 'www.website.com/contact-us' and '/contact-us' both are not working is it because my cms is under another cms page? so it's actually a sub menu of a cms page. Help! Link to comment Share on other sites More sharing options...
igi008 Posted July 3, 2015 Share Posted July 3, 2015 (edited) Hi, I tried vekia's code but instead my whole website just went blank. May I know the url what kind of format that I need to use? I tried 'www.website.com/contact-us' and '/contact-us' both are not working is it because my cms is under another cms page? so it's actually a sub menu of a cms page. Help! I think, both of them are correct (I preffer second way most). But your problem could be with new version of module (actual is 2.2.0 - updated 2 days ago - I had problems after update, I am using older version yet) You can try version 2.1.0 and way described in my post above (updated yrejk's post). In my case works good. Edited July 3, 2015 by igi008 (see edit history) Link to comment Share on other sites More sharing options...
phingko Posted July 3, 2015 Share Posted July 3, 2015 Thanks igi008 for the reply I tried your code as well, the result is the same, i get blank page instead. Really don't understand why it won't work Shouldn't have upgraded it I guess Link to comment Share on other sites More sharing options...
templaries Posted November 26, 2015 Share Posted November 26, 2015 (edited) I put here my own solution to generate custom threes on the top menu with custom links. In blocktopmenu.php replace the for located in line 659 by this for. foreach ($categories as $category) { $cat = new CMSCategory((int)$category['id_cms_category'], (int)$id_lang); $cat_link = ""; if($cat->description === 'link') { $cat_link = $cat->link_rewrite; } else { $cat_link = Tools::HtmlEntitiesUTF8($cat->getLink()); } $this->_menu .= '<li>'; $this->_menu .= $cat->description.'<a href="'.$cat_link.'">'.$category['name'].'</a>'; $this->getCMSMenuItems($category['id_cms_category'], (int)$depth + 1); $this->_menu .= '</li>'; } I use CMS category to build the threes. I decide to use the field "description" to notify that is special link filling "link" value. In this case, you can create a CMS category called "My link", with "link" in descripcion and your link in friendly-url caption. When the description field is "link", the code use the friendly-url. You can put here any link, thus categories links. if($cat->description === 'link') { $cat_link = $cat->link_rewrite; } Edited November 26, 2015 by templaries (see edit history) Link to comment Share on other sites More sharing options...
oxus Posted January 27, 2016 Share Posted January 27, 2016 You need change file: modules/blocktopmenu/blocktopmenu.php foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; if (strpos($cms->meta_description, 'REDIRECT:') !== False) { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.str_replace("REDIRECT:", "", $cms->meta_description).'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } } Don't forget, if you need deactivate top category item link of CMS menu to list of CMS articles, you need change too this section (only remove code inside href): case 'CMS_CAT': $category = new CMSCategory((int)$id, (int)$id_lang); if (count($category)) { $this->_menu .= '<li><a href="" title="'.$category->name.'">'.$category->name.'</a>'; $this->getCMSMenuItems($category->id); $this->_menu .= '</li>'.PHP_EOL; } break; I use this solution and is working on 1.6.1.3. I use this to put tag links in top menu. Because tag menu have invalid carachters (+, =, ?) I use this tutorial to extend tinyMCE and disable auto-paragraph adding : https://mypresta.eu/en/art/prestashop-16/extended-rich-text-editor.html and I use $content to put my link. My code is: if (strpos($cms->content, 'REDIRECT:') !== False) { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.str_replace("REDIRECT:", "", $cms->content).'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } The blank page problem is most likely because of closing tags after "else" zone } } Link to comment Share on other sites More sharing options...
silvioscavone Posted March 13, 2016 Share Posted March 13, 2016 (edited) Hi all guys, I'm trying to do the same with different languages. I need to do some thing like: if ($cms->id==13){ $this->_menu .= '<li '.$selected.'>'; if SELECTED LANGUAGE BY USER IN FRONT OFFICE IS ITALIAN <- how to write this??? { link in Italian below $this->_menu .= '<a href="http://newsite.rimaoil.it/listini/listino_raccordi_tubo_flessibile.pdf" target="_blank">'.$cms->meta_title.'</a>'; } else if SELECTED LANGUAGE BY USER IN FRONT OFFICE IS ENGLISH <- how to write this??? { link in English below $this->_menu .= '<a href="http://newsite.rimaoil.it/listini/flexible_hose_pricelist.pdf" target="_blank">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } ... else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } Anyone can help? Thank you very much guys Edited March 13, 2016 by silvioscavone (see edit history) Link to comment Share on other sites More sharing options...
timelife Posted March 6, 2017 Share Posted March 6, 2017 I was edit this code in modules/blocktopmenu/blocktopmenu.php to change links of subcategories but it does not working. what should i do? foreach ($categories as $category) { $cat = new CMSCategory((int)$category['id_cms_category'], (int)$id_lang); if ($cat->id==27){ $this->_menu .= '<li>'; $this->_menu .= '<a href="http://timelife.vn/12-san-pham#/gioi_tinh-nam">'.$category['name'].'</a>'; $this->_menu .= '</li>'; } elseif ($cat->id==28){ $this->_menu .= '<li>'; $this->_menu .= '<a href="http://timelife.vn/12-san-pham#/gioi_tinh-nu">'.$category['name'].'</a>'; $this->getCMSMenuItems($category['id_cms_category'], (int)$depth + 1); $this->_menu .= '</li>'; } else { $this->_menu .= '<li>'; $this->_menu .= '<a href="'.Tools::HtmlEntitiesUTF8($cat->getLink()).'">'.$category['name'].'</a>'; $this->getCMSMenuItems($category['id_cms_category'], (int)$depth + 1); $this->_menu .= '</li>'; } } Link to comment Share on other sites More sharing options...
hornet85 Posted August 9, 2017 Share Posted August 9, 2017 If i were you i will create CMS page then in blocktopmenu.php file instead of: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } use this: foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int)$id_lang); $links = $cms->getLinks((int)$id_lang, array((int)$cms->id)); $selected = ($this->page_name == 'cms' && ((int)Tools::getValue('id_cms') == $page['id_cms'])) ? ' class="sfHoverForce"' : ''; if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } else { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.$links[0]['link'].'">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>'; } } if ($cms->id==4) - this is if condition with ID of gallery cms page. instead of "URL_TO_GALLERY" use url to your gallery page Hi, I know it's a old post, but the thread is the same of my question: is it possible to adapt this solution also to products category? I mean if is it possible, in the top horizontal menu, to add a custom link in the subcategory window. Link to comment Share on other sites More sharing options...
hornet85 Posted August 11, 2017 Share Posted August 11, 2017 no one can help? Link to comment Share on other sites More sharing options...
gunril Posted September 15, 2017 Share Posted September 15, 2017 Hello, Trying to search the same solution to place a external link on a cms id page like vekia explaned, but i need this for prestashop 1.7.2 in the ps_mainmenu.php file. where and how (same code for 1.7 ?) can i place this solution ? if ($cms->id==4){ $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="URL_TO_GALLERY">'.$cms->meta_title.'</a>'; $this->_menu .= '</li>';} else { Link to comment Share on other sites More sharing options...
Sivile Posted February 6, 2019 Share Posted February 6, 2019 Hi! Same problem in prestashop 1.7...some help¿? Link to comment Share on other sites More sharing options...
gabiferbe Posted March 24, 2020 Share Posted March 24, 2020 Hi please help i have the same problem in prestashop 1.7 HELP! :c 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