Iron giant Posted July 14, 2014 Share Posted July 14, 2014 Anyone please help me on this issue I have a module suppose its called "mymodule". I want to show the module content on a unique position, i.e prestashop already provided many types of hooks, but other than this I want to create new unique hook which will placed into a unique position and in that unique position, i want to show my module content. please help me guys. Thank you Link to comment Share on other sites More sharing options...
vekia Posted July 14, 2014 Share Posted July 14, 2014 hello for example, you created hook with name: dispalyMyPosition then your module must have function: public function hook displayMyPosition($params){ //do something } remember to transplant module to this hook under modules > positions tab 1 Link to comment Share on other sites More sharing options...
Iron giant Posted July 14, 2014 Author Share Posted July 14, 2014 Hello vekia, thanks for the reply. I have just created a banner module. but i dont know how to create a hook. I have followed many tutorials. but couldn't get success on this. Can you tell me step by step process for this issue? 1) how to create hook 2) how to create unique position for it , which will be available whenever my module will be installed. i have written mydsiplayposition in my module. but have not create any hook called mydisplayposition, because i dont know. i am really stuck on it. and i guess i have to write for example in tpl file {$HOOK_myposition} also. I am confused. please help me. thank you Link to comment Share on other sites More sharing options...
Genie Posted July 14, 2014 Share Posted July 14, 2014 hello you have to register a hook first in your module's install function function install() { if (!parent::install() OR !$this->registerHook('header') OR !$this->registerHook('footer') ) return false; return true; } Then you eill have to define that hooks function hookHeader($params) { $result = ''; $result .= $this->_addCss('css/'.$this->name.'.css'); $result .= $this->_addJs('js/min.js'); $result .= $this->_addJs('js/pack.js'); return $result; } function hookFooter($params) { return $this->display(__FILE__, 'views/templates/hook/'.$this->name.'.tpl');; } Now install your module and configure it. Click on manage hook at the top right corner. then click on transplant a module. Select your module name from the drop down list of module then select displayFooter (Footer) as hook into because you have registered footer hook in your module and in the definition you have rendered the view file of your module in the footer hook. then click on save button you can see your module in footer. Link to comment Share on other sites More sharing options...
vekia Posted July 14, 2014 Share Posted July 14, 2014 no it's not necessary to register hook in the module you can just transplant it to that hook under modules > positions tab with "transplant" tool Link to comment Share on other sites More sharing options...
Iron giant Posted July 14, 2014 Author Share Posted July 14, 2014 hello, Thanks but in your post you have written all predefined hooks or position. But in my case i want to create a new position (i.e. a custom hook for my website) where i can set any module of mine or can set any downloaded module in that custom position. Thanks Link to comment Share on other sites More sharing options...
Iron giant Posted July 14, 2014 Author Share Posted July 14, 2014 hello vekia, Thanks for the reply I just want my hooks to show in the drop down modules-> positions Hook which is created by me and suppose it will show on footer area. I can set any module in that position using the custom hook from (modules-> positions )which is created by me. i just want to create a proper hook like prestashop already have predefined (displayRight, displayLeft etc etc). for example my hook will be called "mydisplayposition", which can selected from modules->positions in admin panel. I just want my module or any module to show in my created positions, not in predefined positions which prestashop provided already. Thanks Link to comment Share on other sites More sharing options...
vekia Posted July 14, 2014 Share Posted July 14, 2014 Step 1 : Open PphMyAdmin .find your shop database and open it. in prestashop you need to create one Row in "ps_hook" table. first open ps_hook table and Insert new Row and name it for example displayTop2 . you just need to fill name and title field's.not any other values needed. Link to comment Share on other sites More sharing options...
Iron giant Posted July 14, 2014 Author Share Posted July 14, 2014 hello vekia, i have insert a new row in the ps_hook table "displayTop2" and what are the steps afterwards ? suppose i have to show the editorial module content in this position "displayTop2". so what to do now? in the module editorial . i have wriitent the following . in the editorial.php public function hookdisplayTop2() { echo "HELLO WORLD"; } and i have to see this in footer.tpl so in footer.tpl i have wrote this {$HOOK_TOP2} but couldn't get anything Please help. thanks Link to comment Share on other sites More sharing options...
vekia Posted July 14, 2014 Share Posted July 14, 2014 instead of {$HOOK_TOP2} use {hook::exec('displayTop2')} 2 Link to comment Share on other sites More sharing options...
Iron giant Posted July 14, 2014 Author Share Posted July 14, 2014 Hello vekia, Thank you so so much. It worked finally. Thank you thank you.. Link to comment Share on other sites More sharing options...
patelakash317 Posted August 4, 2015 Share Posted August 4, 2015 Thank you.. Link to comment Share on other sites More sharing options...
rohit_prakash95 Posted March 4, 2017 Share Posted March 4, 2017 hi guys, I am new in module development. how to add javascript in head section of pristashop 1.7 I need to add following code in head <script src="https://clientcdn.pushchant.com/core/rp.js"></script> <script>_pe.subscribe();</script> and tell me how to add service worker in root of prestashop directory using module http://stackoverflow.com/questions/42595508/how-to-add-script-in-head-section-of-prestashop Link to comment Share on other sites More sharing options...
kapka Posted March 14, 2018 Share Posted March 14, 2018 Hi rohit_prakash95 try this: $this->context->controller->registerJavascript('mymodule', '/js/rp.js', ['position' => 'top']); Link to comment Share on other sites More sharing options...
tksaha11 Posted March 25, 2018 Share Posted March 25, 2018 Please help!!! This is my module page, listCatagory.php This is my theme's header file. header.tpl I want to show the module after blockPosition3 and before 4. How can I do that?? 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