Jump to content
thirty bees forum
  • 0

Is it possible to hook modules into CMS pages?


Question

Posted

I had found this tutorial by Nemo, but it does not appear to work for me on TB:

https://www.prestashop.com/forums/topic/351932-free-tutorial-how-to-add-hooks-to-prestashop-cms-pages/

19 answers to this question

Recommended Posts

  • 0
Posted

After modifying the code in cms.tpl, assuming you did it right, as that tutorial is pretty old, and the code is different in tb. And after you modified your module you wanted to add to the cms page, did you then reset that module, so the new hook would become active?

  • 0
Posted

I did reset the module, no dice. The code is not all that different, but it is hard for me to tell where the small modifications would make a difference in terms of the functionalities.

  • 0
Posted

and...in the top of the module, under function install, does it have a line similar to this: || !$this->registerHook('displayHomeTab')

It needs to have that hook, and then the new hook you add to it: || !$this->registerHook('customCMS')

for this to work. Plus of course the new function you added to the module: public function hookcustomCMS($params) { return $this->hookDisplayHome($params); }

  • 0
Posted

if you goto BO>Modules and Services>Positions and check the Display non-positionable hooks check box, then pick your Testimonials module to show, does it have a listing for customCMS, and the Testimonials module under it?

  • 0
Posted

I followed @Nemo 's tutorial, adding the hook to module homefeatured, and it worked just as he said, in tb103 and in tb104. So you must have done something wrong. Lets figure out what it is.... To start with answer my last question, and we'll go from there.

You might start fresh, and modify homefeatured like the example was, and see if you can get that working, and if you can, go back to modifying your Testimonials module. Thats a pretty simple module, I suspect your Testimonials module is not.

  • 0
Posted

Then the problem is how you installed the hook in 'function install' in the testimonials module, this part: || !$this->registerHook('customCMS')

show me the install function of the testimonials module, and we'll get this fixed.

  • 0
Posted
/**  Function Install Module **/
    public function install()
    {
        if (parent::install()
            && $this->registerHook('actionShopDataDuplication')
            && $this->registerHook('home')
            && $this->registerHook('displayHeader')
            && $this->registerHook('customCMS_AFTER'))
        {
            $this->setDataBase('add');
            $this->installDemo();
            return true;
        }
        return false;
    }
  • 0
Posted

change this: && $this->registerHook('customCMS_AFTER')) to this: && $this->registerHook('customCMS'))

Then reset the module. This is assuming that you setup your hook in the module like this: public function hookcustomCMS($params) { return $this->hookDisplayHome($params); }

The functions name, and the registerhooks name needs to be the same. in this case hookcustomCMS

  • 0
Posted

I did a customCMSBEFORE and a customCMSAFTER, inside the CMS page, as described in the tutorial, so that I could put stuff before or after the CMS code itself. Hence the labeling. But I do know that they need to match everywhere (and currently they do).

  • 0
Posted

Not inside the module, inside the CMS tpl file, there are two hooks created, one CMSBEFORE and one CMSAFTER. Inside the module, I only want to use CMS_AFTER as I want the module to appear after any CMS content.

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...