Jump to content

Moving Home Slider to newly created hook


Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...