439
edits
No edit summary |
(→Implementation: rename to Usage and fix some mistakes) |
||
| Line 7: | Line 7: | ||
= | = Usage = | ||
To use a hook (add or replace a part of code), you first need to already have defined a module (see the wiki for that), and then you need to do 2 things: | To use a hook (add or replace a part of code), you first need to already have defined a module (see the wiki for that), and then you need to do 2 things: | ||
| Line 13: | Line 13: | ||
1- add your module to the list of contexts you want to hook on. | 1- add your module to the list of contexts you want to hook on. | ||
This means that when a context you hook will happen, your module hook code will be called. | This means that when a context you hook will happen, your module hook code will be called. | ||
To do that, just edit your '''/htdocs/''yourmodulename''/modules/mod''YourModuleName''.class.php''' and edit the '''$this->module_parts''' variable with something like this: | To do that, just edit your '''/htdocs/''yourmodulename''/core/modules/mod''YourModuleName''.class.php''' and edit the '''$this->module_parts''' variable with something like this: | ||
<source lang="php"> | <source lang="php"> | ||
$this->module_parts = array( | $this->module_parts = array( | ||
| Line 21: | Line 21: | ||
Of course change YourModuleName with your own module's name. | Of course change YourModuleName with your own module's name. | ||
Note: you can access the current module's context with print('Module context: '.$object->context); (put this inside the module's php file where the hook resides) | |||
'''IMPORTANT''': Be careful: do not forget to DISABLE then RENABLE the module in the admin panel to accept the new context, because these constants are only added to the database when enabling the module. | '''IMPORTANT''': Be careful: do not forget to DISABLE then RENABLE the module in the admin panel to accept the new context, because these constants are only added to the database when enabling the module. | ||
edits