hooks, how to ?

Hooks, how to ?, a forum discussion on Jojo CMS. Join us for more discussions on Hooks, how to ? on our General Discussion forum.

Back to Forum Index : Back to General Discussion   RSS
glouk glouk

7 Jun 2008
Posts: 46

I'd like to have some insight about using hooks...

It is said in the documentation that hooks can be used in smarty templates, how ?

I'd like to use the {customhead} hook, and i don't know how.

First i installed the block_head smarty plugin, but it does not work. don't know why...

Core Developer


7 Jun 2008
Posts: 327

The customhead hook is a special case - a little different to other hooks.

If you want to insert some sitewide code into the document head, create a template called "customhead.tpl" in any plugin or theme and run setup. The code in this file will be incorporated into the head.

To see an example of a regular hook, have a look at the jojo_blogicons plugin to see how it adds it's blogicons to one of the hooks in the jojo_article template.

In short, to add a hook you need to make an entry in api.php
Jojo::addHook('hook_you_want_to_use', 'custom_function_to_run', 'plugin_name');

Next, create a function in your plugin (plugin name and function name must match what you declared above).
function custom_function_to_run(){return 'some content to insert at the hook point';}

Normally you will want to fetch some content from a smarty template, but you can return any string. If you need to use Smarty, you will need to add the line 'global $smarty;' to give your function access to the Smarty object.
Back to Forum Index : Back to General Discussion   RSS
You must be logged in to post a reply

You need to Register or Log In before posting on these forums.