Archer Posted October 22, 2013 Share Posted October 22, 2013 (edited) Hi ! I'm a web developper, i've just started to work with prestashop and i have to create a theme for prestashop 1.5.4.1 (based on photoshop design). I've created a new hook called displayNav and placed it in the header.tpl of my theme. I've edited the blocktopmenu's css and placed it in : 'prestashop/themes/mytheme/css/modules/blocktopmenu/css/superfish-modified.css I've edited the blocktopmenu's php file and added this method : public function hookDisplayNav($param) { return $this->hookDisplayTop($param); } And the hookDisplayTop method : public function hookDisplayTop($param) { $this->user_groups = ($this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP'))); $this->page_name = Dispatcher::getInstance()->getController(); if (!$this->isCached('blocktopmenu.tpl', $this->getCacheId())) { $this->makeMenu(); $this->smarty->assign('MENU_SEARCH', Configuration::get('MOD_BLOCKTOPMENU_SEARCH')); $this->smarty->assign('MENU', $this->_menu); $this->smarty->assign('this_path', $this->_path); } $this->context->controller->addJS($this->_path.'js/hoverIntent.js'); $this->context->controller->addJS($this->_path.'js/superfish-modified.js'); $this->context->controller->addCSS($this->_path.'css/superfish-modified.css'); $html = $this->display(__FILE__, 'blocktopmenu.tpl', $this->getCacheId()); return $html; I've reset the module in the backoffice. It's hooked to displayTop and some actionsHook. If I add a hook to the hook displayNav, everything works fine (it finds the css, the template and display what I want at the correct spot). The problem is, it's appears twice (displayTop & displayNav) But, if I unhook the module from the displayTop hook, the module is displayed once, but no css, js or template is loaded in the "head" of the page. I already have edited the bocknewsletter css, and i didn't have any problem. I don't know what to do ! I'd rather find the right way to do it, but i'll accept any disgusting solution Thanks for your help ! (and sorry for my english !) Edited October 22, 2013 by Archer (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted October 22, 2013 Share Posted October 22, 2013 if i were you i will use this: public function hookDisplayNav($param) { $this->user_groups = ($this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP'))); $this->page_name = Dispatcher::getInstance()->getController(); if (!$this->isCached('blocktopmenu.tpl', $this->getCacheId())) { $this->makeMenu(); $this->smarty->assign('MENU_SEARCH', Configuration::get('MOD_BLOCKTOPMENU_SEARCH')); $this->smarty->assign('MENU', $this->_menu); $this->smarty->assign('this_path', $this->_path); } $html = $this->display(__FILE__, 'blocktopmenu.tpl', $this->getCacheId()); return $html; } public function hookDisplayTop($param){ $this->context->controller->addJS($this->_path.'js/hoverIntent.js'); $this->context->controller->addJS($this->_path.'js/superfish-modified.js'); $this->context->controller->addCSS($this->_path.'css/superfish-modified.css'); } and ofcourse dont remove displayTop hook Link to comment Share on other sites More sharing options...
Archer Posted October 22, 2013 Author Share Posted October 22, 2013 I feel so dumb right now ! It worked perfectly ! You are truly a legend Many thanks to you ! Link to comment Share on other sites More sharing options...
Archer Posted October 22, 2013 Author Share Posted October 22, 2013 I feel so dumb right now ! It worked perfectly ! You are truly a legend Many thanks to you ! Link to comment Share on other sites More sharing options...
Archer Posted October 22, 2013 Author Share Posted October 22, 2013 I feel so dumb right now ! It worked perfectly ! You are truly a legend Many thanks to you ! Link to comment Share on other sites More sharing options...
Jude_AAZ Posted March 24, 2014 Share Posted March 24, 2014 I suggest to use displayHeader hook for such JS and CSS ! 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