movieseals Posted March 6, 2018 Posted March 6, 2018 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/
0 SLiCK_303 Posted March 14, 2018 Posted March 14, 2018 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 movieseals Posted March 16, 2018 Author Posted March 16, 2018 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 SLiCK_303 Posted March 16, 2018 Posted March 16, 2018 What module did you try and add to the cms pages?
0 SLiCK_303 Posted March 16, 2018 Posted March 16, 2018 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 movieseals Posted March 16, 2018 Author Posted March 16, 2018 Yes, I did that as well inside the code of the module itself.
0 SLiCK_303 Posted March 16, 2018 Posted March 16, 2018 but it already had the displayHomeTab hook and function in the module right? And you just added the hook and function customCMS...
0 movieseals Posted March 16, 2018 Author Posted March 16, 2018 Yes, it did. It is inhenrently designed to use displayHomeTab
0 SLiCK_303 Posted March 16, 2018 Posted March 16, 2018 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 SLiCK_303 Posted March 17, 2018 Posted March 17, 2018 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 movieseals Posted March 22, 2018 Author Posted March 22, 2018 Hi! Sorry for the delay! Busy week. No, the hooks do not appear.
0 SLiCK_303 Posted March 23, 2018 Posted March 23, 2018 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 movieseals Posted March 23, 2018 Author Posted March 23, 2018 /** 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 SLiCK_303 Posted March 23, 2018 Posted March 23, 2018 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 movieseals Posted March 23, 2018 Author Posted March 23, 2018 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 SLiCK_303 Posted March 23, 2018 Posted March 23, 2018 so you have two function inside the module? One being function hookcustomCMSBEFORE and one function hookcustomCMSAFTER ?
0 movieseals Posted March 23, 2018 Author Posted March 23, 2018 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.
0 SLiCK_303 Posted March 23, 2018 Posted March 23, 2018 Yea, we got it working!! Love it when a plan comes together!
0 movieseals Posted March 23, 2018 Author Posted March 23, 2018 Thank you very much for all your help!
Question
movieseals
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
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