====== Hooks ======
Hooks are a more dynamic way of manipulate with pluck than the current system. The current system is based on files, and the names of them. pluck looks for a specific file and then does something with it. The new system is based on functions, and are much more flexible. Do you want to add an extra menu in the admin panel? You are now able to do that. This document will show the idea behind hooks, and how to use them.
function PREFIX_info() {
$module_info = array(
'name' => 'test module',
'intro' => 'Created to show the new hooks.',
'version' => '0.1',
'author' => 'Anders Jørgensen',
'website' => 'http://spirit55555.dk',
'icon' => 'images/test.png',
'compatibility' => '4.7'
);
return $module_info;
}
You can change the info as you like.
Two things you should note:
* The module name does not have to be the same as the folder.
* PREFIX is the name of the module folder. In this case it should be //test//. **All function should start with that, or else they won't work.**
The module now shows up in //options -> manage modules//, but it's not "hooking" anything yet.
==== The first hook ====
Developers can run hooks anywhere they want in pluck. In the core, in themes and even in modules. That will be explained later, because right now, we are focusing on how to add something to an existing hook.
This tutorial will show how to add some CSS in the admin panel, so the font color becomes pink or any other color you like.
There is a hook called **admin_header_main** between
function PREFIX_admin_header_main() {
echo '';
}
And that's it! You don't have to do anything more. This is how every hook works.
Just create a function starting with **PREFIX_**, and then the hook name (in this case it was //admin_header_main//).
===== Include your module in a page =====