Hotaru Docs

 [həʊdɒks]

Plugin Hook Basics

Plugin hooks allow developers to add functionality to Hotaru CMS or other plugins. A typical plugin hook looks like this:

In a plugin

$h->pluginHook('hook_name');

In a template

<?php $h->pluginHook('hook_name'); ?>

Some plugin hooks are built into Hotaru and themes, others are custom hooks that plugin developers ask users to add to their themes. The only significant difference between the two is that a custom hook uses a name chosen by the plugin developer, usually the name of the plugin. Here are examples of each:

$results = $h->pluginHook('theme_index_top');
<?php $h->pluginHook('rss_show'); ?>
In order for your plugin to use a hook, you must include the hook's name at the top of your plugin file, eg.
* hooks: theme_index_top

Then, you need a function with the same name as the hook, e.g.

public function theme_index_top($h)
{
...
// your code
...
}

Note that if you want your plugin to output something, you should echo it from within the function instead of returning it, e.g.

public function hello_world($h)
{
    echo "Hello World!";
}

See Using the pluginHook() function for advanced usage.

Getting StartedDesign and LayoutPlugin DevelopmentAdvanced TopicsFunction ReferenceTroubleshooting