babyewok Posted February 21, 2014 Share Posted February 21, 2014 I have created a new hook on the homepage and am trying to attach the default home slider (I have PS 1.5.6.2) to this new hook instead of the usual Hook_Home. I added this to the index.tpl: {hook h='DisplayHomeTop'} Then in Homeslider.php I simply replaced instances of DisplayHome with DisplayHomeTop: /* Adds Module */ if (parent::install() && $this->registerHook('DisplayHomeTop') && $this->registerHook('actionShopDataDuplication')) { public function hookDisplayHomeTop() { if(!$this->_prepareHook()) return; // Check if not a mobile theme if ($this->context->getMobileDevice() != false) return false; $this->context->controller->addJS($this->_path.'js/jquery.bxSlider.min.js'); $this->context->controller->addCSS($this->_path.'bx_styles.css'); $this->context->controller->addJS($this->_path.'js/homeslider.js'); return $this->display(__FILE__, 'homeslider.tpl', $this->getCacheId()); } The hook seems to have been created just fine and the slider is attached where it should be, only that it isn't working (I just see a bulleted list of images). If I try to attach it to BOTH hooks, so add DisplayHomeTop to homeslider.php IN ADDITION TO DisplayHome, then it works in the new hook, but shows a bulleted list in the usual home hook. If I then remove the module from the home hook in the back office, it now stops working in the new hook! There is obviously something I am missing, but I have no idea what! Please help! Link to comment Share on other sites More sharing options...
vekia Posted February 21, 2014 Share Posted February 21, 2014 create separate hook name displayHeader and create function to handle this hook with $this->context->controller->addJS($this->_path.'js/jquery.bxSlider.min.js'); $this->context->controller->addCSS($this->_path.'bx_styles.css'); $this->context->controller->addJS($this->_path.'js/homeslider.js'); Link to comment Share on other sites More sharing options...
babyewok Posted February 21, 2014 Author Share Posted February 21, 2014 OK I wil try that - I don't get though why the above info is added to the header when using the DisplayHome hook and not when using the new hook when using the same function. Link to comment Share on other sites More sharing options...
babyewok Posted February 21, 2014 Author Share Posted February 21, 2014 You star, that has sorted it! Thank you so much Link to comment Share on other sites More sharing options...
vekia Posted February 22, 2014 Share Posted February 22, 2014 you're welcome it looks like addCSS and addJS doesn't want to work with non default hooks, anyway, the best hook to place these files is hookHeader Link to comment Share on other sites More sharing options...
babyewok Posted February 24, 2014 Author Share Posted February 24, 2014 (edited) Oh I see - thanks for shedding some light on that for me Edited February 24, 2014 by babyewok (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