Ben Rich Posted November 19, 2011 Share Posted November 19, 2011 Hi, I wonder if anyone can help point me in the right direction (i've done a lot of googling already). I've created a module that does everything I want it to in the back office. I now need some front office behaviour. There are plenty of hooks but I'd rather have a whole page to myself. Some background: My module associates passwords with groups. On this page I want to allow users to enter a password and assuming its correct, add them to a specified group. Assuming its possible to do this, how would I go about associating a front office page with my module? Or something similar if needs be. Thanks! Link to comment Share on other sites More sharing options...
MeRuud Posted November 20, 2011 Share Posted November 20, 2011 Hi! Here is a page with all of the available hooks: http://www.nethercottconstructions.com/en/content/52-prestashop-module-hooks I think your looking for hooking your plugin to a CMS page, not sure if this is possible. Thanks, Ruud Link to comment Share on other sites More sharing options...
Ben Rich Posted November 20, 2011 Author Share Posted November 20, 2011 Yeah I found the same list of hooks and realised none helped. You did though give me a few new search terms to try, which helped. eg. Creating my own hook: http://www.prestashop.com/forums/topic/129386-display-newsletter-block-in-a-cms-page/page__view__findpost__p__641992 I've now done that. My module can now interact with a CMS page, which is great. From the above link it would be nice not to have to edit core files (steps 3 & 4). I'll look into an alternative at some point (unless someone knows of one off hand). Link to comment Share on other sites More sharing options...
MeRuud Posted November 20, 2011 Share Posted November 20, 2011 You can overwrite core files by doing the following: Classes: As an example, you can add a date_add field to the ps_cms table, then override the CMS class to add a publish date to CMS pages by creating the file override/classes/CMS.php and inserting the following into the file: <?php class CMS extends CMSCore { public date_add; public function getFields() { $fields = parent::getFields(); $fields['date_add'] = pSQL($this->date_add); return $fields; } } ?> Controllers: As an example, you can override the category listings to add a new hook for modules to use by creating the file override/controllers/CategoryController.php and inserting the following code into the file: <?php class CategoryController extends CategoryControllerCore { public function process() { parent::process(); self::$smarty->assign('HOOK_CATEGORY', Module::hookExec('category')); } } ?> Or read more here: http://www.nethercottconstructions.com/en/content/category/9-overriding-files Link to comment Share on other sites More sharing options...
Ben Rich Posted November 21, 2011 Author Share Posted November 21, 2011 Problems with overriding core files or the stuff in my initial post? I haven't looked into overriding files yet. If its to do with associating a module with a CMS page, i've managed to now do that successfully. After following the instructions within my 2nd post, I added a function (in my module) called hookHookName (replace 'HookName' with whatever you want). Register the hook during install ($this->registerHook(hookName)). May need to 'transplant a module' if you dont want to reinstall your module again. Then, every time i visit the CMS page, any code within that function is executed. 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