Jump to content

My own modules and hooks?


Recommended Posts

I would like to add extra columns with content in the footer which doesn't exist in the way i'd like. On a normal website I would have just created it simply by markup and css. But I understand that PS has certain "rules" about such things, and I would like to follow those for it to be easy for others in the future to alter it.

However, I'm not sure of how to go about it. 

 

How do I create a simple module where I can put my html?

 

Also, how do I create a new hook?

Link to comment
Share on other sites

hello

 

strange that it doesnt work for you

im using this method to create non default hooks and... it works, for each 1.5.x version

 

may i know what hook you added and how? and in addition, what code you use in your module to handle this hook?

Link to comment
Share on other sites

I did it from the beginning with a new one so it's clean for the example, hopefully you can see where I'm doing it wrong :/

 

 

  • Log into phpmyadmin

  • Click ps_hook

  • Click to add

  • Enter 'displayMenu2' into the fields 'name' and 'title'

  • Click run

  • Download FrontController.php from classes>controller>

  • Open up and search for 'HOOK_HEADER' => Hook::exec('displayHeader'),

  • Add this underneath the above mentioned: 'HOOK_MENU2' => Hook::exec('displayMenu2'),

  • Search for 'HOOK_TOP' => Hook::exec('displayTop'),

  • Add this underneath the above mentioned: 'HOOK_MENU2' => Hook::exec('displayMenu2'),

  • Add the new FrontController.php to override>controllers

  • Open up header.tpl from my theme

  • Add this in there: {$HOOK_displayMenu2}

  • Upload header.tpl

  • Log into my prestashop admin

  • Click modules and transplant a module

  • Transplant Top horizontal menu into displayMenu2, and I get "This module cannot be transplanted to this hook."

  • Download the module-files for the menu

  • Open blocktopmenu.php

  • Search for top, and this line comes up first: public function hookDisplayTop($param) (and so forth)

  • Add this underneath that full code: function hookdisplayMenu2($params) {

    return $this->hookhome($params, 'displayMenu2');

    }

  • Upload

  • Still get: "This module cannot be transplanted to this hook."

Link to comment
Share on other sites

  • 3 weeks later...

Replaced {$HOOK_displayMenu2} with {$HOOK_MENU2} in header.tpl.

Yes, the new hook appears in the database.

 

I still get this :(

 

Notice: Undefined index: HOOK_MENU2 in /storage/content/21/104221/website.se/public_html/cache/smarty/compile/87/88/21/878821c06e433b5fc177942e9804ae4e0e6f5a4c.file.header.tpl.php on line 160 Notice: Trying to get property of non-object in /storage/content/21/104221/website.se/public_html/cache/smarty/compile/87/88/21/878821c06e433b5fc177942e9804ae4e0e6f5a4c.file.header.tpl.php on line 160

Link to comment
Share on other sites

Woops, forgot about that the 1.6 probably uses different codes now. So used {hook h="MENU2"} instead and now it doesn't give off that error. :) 

 

Still can't transplant the menu to it though. Should I change this in the blocktopmenu.tpl to something else?

public function hookdisplayMenu2($params) {
return $this->hookhome($params, 'displayMenu2');
}
 
Thank you for your help! It's very helpful to use this forum, I get to learn fast.
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...