NelutuO Posted April 18, 2014 Share Posted April 18, 2014 Hi. I want to create a new hook, transplant the horizontal menu into it and place it right after the TOP_HOOK, in the header. Can anyone explain me how to do it, or point me to a tutorial? Thank you. Link to comment Share on other sites More sharing options...
vekia Posted April 18, 2014 Share Posted April 18, 2014 create new hook in your prestashop database, for example with name "AfterTop" then in module php file use this function: public function hookAfterTop($params){ return $this->hookDisplayTop($params); } 1 Link to comment Share on other sites More sharing options...
NelutuO Posted April 18, 2014 Author Share Posted April 18, 2014 Thank you very much. It works perfectly. Link to comment Share on other sites More sharing options...
vekia Posted April 18, 2014 Share Posted April 18, 2014 you're welcome :-) glad to hear that i could help you a little i marked this topic title as solved with regards Milos Link to comment Share on other sites More sharing options...
Ron morales Posted May 7, 2014 Share Posted May 7, 2014 (edited) ps 1.6 i need add in blocktop menu, one tab and blockcart this hook successfully created , but do not appear in the top menu Edited May 7, 2014 by Ron morales (see edit history) Link to comment Share on other sites More sharing options...
Ron morales Posted May 7, 2014 Share Posted May 7, 2014 (edited) in header.tpl yes work but , themes/name/blocktopmenu not work <!-- Menu --> <div id="block_top_menu" class="sf-contener clearfix col-lg-12"> <div class="cat-title">{l s="Categories" mod="blocktopmenu"}</div> <ul class="sf-menu clearfix menu-content"> {$MENU} {if $MENU_SEARCH} li class="sf-search noBack" style="float:right"> <form id="searchbox" action="{$link->getPageLink('search')|escape:'html':'UTF-8'}" method="get"> <p> <input type="hidden" name="controller" value="search" /> <input type="hidden" value="position" name="orderby"/> <input type="hidden" value="desc" name="orderway"/> <input type="text" name="search_query" value="{if isset($smarty.get.search_query)}{$smarty.get.search_query|escape:'html':'UTF-8'}{/if}" /> </p> </form> </li> {/if} <!--principio inicio sesion--> {if $is_logged} <li> <a href="{$link->getPageLink('my-account', true)|escape:'html':'UTF-8'}" title="{l s='View my customer account' mod="blocktopmenu"}" class="account" rel="nofollow"><span><!--{$cookie->customer_firstname} {$cookie->customer_lastname}-->{l s='Mi cuenta' mod="blocktopmenu"}</span></a> </li> {/if} <li> {if $is_logged} <a class="logout" href="{$link->getPageLink('index', true, NULL, "mylogout")|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Log me out' mod="blocktopmenu"}"> {l s='Salir' mod="blocktopmenu"} </a> {else} <a class="login" href="{$link->getPageLink('my-account', true)|escape:'html':'UTF-8'}" rel="nofollow" title="{l s='Login to your customer account' mod="blocktopmenu"}"> {l s='Entrar' mod="blocktopmenu"} </a> {/if} </li><!--fin inicio sesion--> <!-- /Block usmodule NAV --> <li><a>carrito{$HOOK_CARRITO}</a></li> </ul> </div> <!--/ Menu --> Edited May 7, 2014 by Ron morales (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted May 8, 2014 Share Posted May 8, 2014 regenerate block top menu module, open configuration page of this addon and hit save. this module needs to be recompiled. Link to comment Share on other sites More sharing options...
Ron morales Posted May 8, 2014 Share Posted May 8, 2014 thanks solved with your post, block cart under blocktopmenu and <li></li></ul> in blockcart thanks and remove taks of blocktopmenu Link to comment Share on other sites More sharing options...
elisa.foschini Posted May 16, 2014 Share Posted May 16, 2014 (edited) Hi, forgive me if I can't explain myself properly, I am a newbie to PS! I am making some training/testing with PS 1.6.I dowloaded a module called Configurable Header Links. It displays link titles, arranged horizontally.It automatically goes hooked to displayTop. Instead, I want to hook it at the very top of the page, where the block banner is (ideal would be that it overlays the banner, and is displayed in a layer above the banner itself. However, being displayed at the very top, and then the banner will be ok as well!!) Is it possibile? How? I tried to hook it to displayHeader and put in as first element in that hook, but nothing. I also tried to hook it to displayBanner. which is the only other hook to which the block banner was hooked, but that isn't allowed... How can I do? Consider I am a total dummy with coding, so the easiest it is, the better! Thanks! Elisa Edited May 16, 2014 by elisa.foschini (see edit history) Link to comment Share on other sites More sharing options...
coolpapes Posted August 8, 2014 Share Posted August 8, 2014 create new hook in your prestashop database, for example with name "AfterTop" then in module php file use this function: public function hookAfterTop($params){ return $this->hookDisplayTop($params); } I did this and and the menu is in the right location but superfish-modified .css is not loading or something. The menu displays as plain text and when I inspect element superfish is not there. Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 9, 2014 Share Posted August 9, 2014 Hi vekia, I'm trying to use your method for moving the tophorizontalmenu in a different position. 1. I started creating a new field named "AfterTop" in table "ps_hook". Now where i should place this code? public function hookAfterTop($params){ return $this->hookDisplayTop($params); } In blocktopmenu.php file? And then which code i should use in my header tpl file to add the hook? Link to comment Share on other sites More sharing options...
vekia Posted August 10, 2014 Share Posted August 10, 2014 public function hookAfterTop($params){ return $this->hookDisplayTop($params); } In blocktopmenu.php file? that's right, in blocktopmenu.php file, add it like other hook functions, you can place code before last closing bracket } And then which code i should use in my header tpl file to add the hook? {hook::exec('AfterTop')} Link to comment Share on other sites More sharing options...
coolpapes Posted August 15, 2014 Share Posted August 15, 2014 that's right, in blocktopmenu.php file, add it like other hook functions, you can place code before last closing bracket } {hook::exec('AfterTop')} I did exactly as instructed, at least I think I did, and still no css. I just get plain text. What am I doing wrong? I created the hook in DB, added the code to the mod php file and added the new hook to header.tpl with the code provided. Am I missing something? Link to comment Share on other sites More sharing options...
coolpapes Posted August 15, 2014 Share Posted August 15, 2014 I did exactly as instructed, at least I think I did, and still no css. I just get plain text. What am I doing wrong? I created the hook in DB, added the code to the mod php file and added the new hook to header.tpl with the code provided. Am I missing something? Nevermind I fixed it by following Vekia's excellent tutorial: how to move block top menu module to top section Thanks for all you do Vekia Link to comment Share on other sites More sharing options...
vekia Posted August 15, 2014 Share Posted August 15, 2014 oups i forgot about this guide, hehe ;-) i should paste link here Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 18, 2014 Share Posted August 18, 2014 I used the linked guide to add the style but I cannot get it work. I added a new hook {hook::exec('AfterTop')} right before </header> I already added this to my blocktopmenu.php file: public function hookAfterTop($params){ return $this->hookDisplayTop($params); } So I add there the code of the coolpapes guide, now i have this: public function hookAfterTop($params){ public function hookAfterTop($params){ $this->context->controller->addJS($this->_path.'js/hoverIntent.js'); $this->context->controller->addJS($this->_path.'js/superfish-modified.js'); $this->context->controller->addJS($this->_path.'js/blocktopmenu.js'); $this->context->controller->addCSS($this->_path.'css/blocktopmenu.css'); $this->context->controller->addCSS($this->_path.'css/superfish-modified.css'); return $this->hookDisplayTop($params); } Unfortunatelly it doesn't works. Link to comment Share on other sites More sharing options...
Arnaud Drieux Posted August 19, 2014 Share Posted August 19, 2014 (edited) Hello, Darkf3d3, I think we have the same problem.With debug mod activated I found $params are not the same between new hook and hook called. Example for me: If I make a var_dump of hookProductFooter $params, that will return all of params. public function hookProductChild($params){ return $this->hookProductFooter($params); } If I make a var_dump of hookProductChild $params that will return all of params except product array (The most important param for my module).So I don't understand where is the problem...Someone can help?Thanks Edited August 19, 2014 by arnaud1900 (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2014 Share Posted August 19, 2014 I used the linked guide to add the style but I cannot get it work. I added a new hook {hook::exec('AfterTop')} right before </header> I already added this to my blocktopmenu.php file: public function hookAfterTop($params){ return $this->hookDisplayTop($params); } So I add there the code of the coolpapes guide, now i have this: public function hookAfterTop($params){ public function hookAfterTop($params){ $this->context->controller->addJS($this->_path.'js/hoverIntent.js'); $this->context->controller->addJS($this->_path.'js/superfish-modified.js'); $this->context->controller->addJS($this->_path.'js/blocktopmenu.js'); $this->context->controller->addCSS($this->_path.'css/blocktopmenu.css'); $this->context->controller->addCSS($this->_path.'css/superfish-modified.css'); return $this->hookDisplayTop($params); } Unfortunatelly it doesn't works. prestashop 1.6 moves all js and css files to footer section make sure that your files arent moved there. Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 19, 2014 Share Posted August 19, 2014 I see the 3 js file just before the </body> but I don't find the 2 .css files (blocktopmenu.css, superfish-modified.css). Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2014 Share Posted August 19, 2014 perhaps you've got CCC for css files option turned on? if so - all css files are minified to one file. Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 19, 2014 Share Posted August 19, 2014 No, I have disabled all ccc and caching because I'm testing the theme on local. Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2014 Share Posted August 19, 2014 your website is online? (i hope so, if it is - please share url) Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 19, 2014 Share Posted August 19, 2014 Yes but it's an old PS1.4.9 inslall, actually I'm testing the PS1.6 responsive theme before making the upgrade. I don't understand why with the code posted above it doesn't add the right css file. Link to comment Share on other sites More sharing options...
Arnaud Drieux Posted August 19, 2014 Share Posted August 19, 2014 Finally I solved it with other method. public function hookChildProduct($params){ //get the Object missing $productVars = new Product((int)$params['id_product']); //transform to array $arrayProductVars = array(); //needed for an other function $arrayProductVars['product'] = $productVars; return $this->hookProductFooter($arrayProductVars); } It's working, but I always don't understood what was the difference between two $params. Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 19, 2014 Share Posted August 19, 2014 You put that code in blocktopmenu.php? (I'm trying to hook it to hookAfterTop but i don't understand how) Link to comment Share on other sites More sharing options...
Arnaud Drieux Posted August 19, 2014 Share Posted August 19, 2014 You put that code in blocktopmenu.php? (I'm trying to hook it to hookAfterTop but i don't understand how) I make that on my own module. But I guess you need to put this code on your blocktopmenu.php Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 19, 2014 Share Posted August 19, 2014 Maybe that fix works only on your specific module, I'm trying but it seem it doesn't works with blocktopmenu. Link to comment Share on other sites More sharing options...
vekia Posted August 19, 2014 Share Posted August 19, 2014 prestashop 1.4 hasn't got $this->context object in prestashop 1.4 you have to use Tools::AddCss and Tools::AddJs instead of funciton in context object also it's worth to mention that ps 1.4 hasn't got displayTop hook, just top so you have to use public $this->hookTop($params) instead of $this->hookDisplayTop($params) Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 19, 2014 Share Posted August 19, 2014 (edited) Maybe on 2 post above I haven't explained well, I require this for PS1.6. My online store actually has the 1.4.9 but the modify I need is for the new template I'm testing on local. Edited August 20, 2014 by DARKF3D3 (see edit history) Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 20, 2014 Share Posted August 20, 2014 prestashop 1.6 moves all js and css files to footer section make sure that your files arent moved there. Hi vekia, do you have the possibility to test the passage of your guide, but instead of using an existing hook with a new one placed right before the closing head tag? Like mine: {hook::exec('AfterTop')} </header> Link to comment Share on other sites More sharing options...
coolpapes Posted August 20, 2014 Share Posted August 20, 2014 (edited) Hi vekia, do you have the possibility to test the passage of your guide, but instead of using an existing hook with a new one placed right before the closing head tag? Like mine: {hook::exec('AfterTop')} </header> To summarize this is what I did: I created a new hook in the DB named "AfterTop" I added the following code to blocktopmenu.php just befor the closing bracket: public function hookAfterTop($params){ return $this->hookDisplayTop($params); } public function hookdisplayHeader($params){ $this->context->controller->addJS($this->_path.'js/hoverIntent.js'); $this->context->controller->addJS($this->_path.'js/superfish-modified.js'); $this->context->controller->addJS($this->_path.'js/blocktopmenu.js'); $this->context->controller->addCSS($this->_path.'css/blocktopmenu.css'); $this->context->controller->addCSS($this->_path.'css/superfish-modified.css'); } Then I added this hook in header.tpl: {hook::exec('AfterTop')} </div> </header> Then I selected the Top Menu module in the BO and clicked on configure and then save to recompile it. That moved the menu to the bottom of the header, after the container div so I could make it full width. I hope this helps clarify things Edited August 20, 2014 by coolpapes (see edit history) 1 Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 20, 2014 Share Posted August 20, 2014 Ok, I do exaclty like your post but no style on blocktopmenu. I start thinking that maybe I made a mistake whit module position. Actually from BO i have the block top menu module attached to: "AfterTop" and "actionCategoryUpdate". It's the same as you? Link to comment Share on other sites More sharing options...
coolpapes Posted August 20, 2014 Share Posted August 20, 2014 Ok, I do exaclty like your post but no style on blocktopmenu. I start thinking that maybe I made a mistake whit module position. Actually from BO i have the block top menu module attached to: "AfterTop" and "actionCategoryUpdate". It's the same as you? I also have it hooked to displayHeader as well as the action hooks and AfterTop Link to comment Share on other sites More sharing options...
DARKF3D3 Posted August 20, 2014 Share Posted August 20, 2014 Great now it's works correctly. Thanks coolpapes! Link to comment Share on other sites More sharing options...
Recommended Posts