68 Classifieds Blog

Features

Adding include templates with modules

Posted on April 21, 2008 by Eric Barnes

Warning: Geek Coding Speak Ahead

New in v4 is the ability to have template hooks which integrate with the module system. This is great for adding new features without having to modify any of the template files themselves. One thing I came across today was wanting to include a template file in the location of the hook.

Inside your mod_user.php file you add a hook function just like normal except make $class_tpl global and return the fetched template. Here is an example:

function example_admin_tpl_userinfo()
{
	global $class_tpl;
	$include = $class_tpl->fetch('orders/customer_table.tpl');
	return $include;
}

Now when the module is installed and the user visits the page with the hook a new template file will be added.

Comments