Jcow Documentation>>

Jcow Hooks API

How to develop hooks

Hook functions are written to a PHP file named YOUR_MODULE_NAME.hook.php
Hook file is not required by a module.

Example:
hook_boot() in test module:
modules/test/test.hook.php
function test_boot() {
	// do something here
	}
	
Back to Top

hook_boot()

This method is called when a visiter's session is begin.
Returns: None
Parameters: None. Example:
modules/test/test.hook.php
function test_boot() {
	// do something here
	}
	
Back to Top

hook_header()

This method is called when the template is about to be loaded.
Returns: Returned content will be written to $header
Parameters: None. Example:
modules/test/test.hook.php
function test_header() {
	// do something here
	return $content;
	}
	
Back to Top

hook_footer()

This method is called when the template is about to be loaded.
Returns: Returned content will be written to $footer
Parameters: None. Example:
modules/test/test.hook.php
function test_footer() {
	// do something here
	return $content;
	}
	
Back to Top

hook_widget()

This method is called when generating user Widgets .
Returns: Returned content will be written to the $widgets
Parameters:
&$widgets: An array of user widgets.
Example:
modules/test/test.hook.php
function test_widget() {
	$widgets['test_widget_hello'] = array(
		'name'=>t('My test widtets'),
		'callback'=>'test_widget_hello'
		);
	$widgets['test_widget_hello2'] = array(
		'name'=>t('My test widtets'),
		'callback'=>'test_widget_hello'
		);
	}

function test_widget_hello() {
	return 'Hello this is a test widget';
	}
function test_widget_hello2() {
	return 'Hello this is the second one';
	}
	
Back to Top

hook_u_menu()

Add Tab menu items to Profile Page.
Returns: None.
Parameters:
&$tab_menu: Current Tab menu of the profile page.
$page: The profile page data.
FieldDescription
$tab_menu['name']Required - Name of the menu item.
$tab_menu['type']Required - value is "tab".
$tab_menu['path']Required - Link of the menu item.
Example(usage):
modules/test/test.hook.php
function test_u_menu(&$tab_menu,$page) {
	$tab_menu[] = array(
		'name'=>'Test',
		'type'=>'tab',
		'path'=>'test/profile/'.$page['id']
		);
}
	
Back to Top

hook_page_menu()

Add Tab menu items to Community Page.
Returns: None.
Parameters:
&$tab_menu: Current Tab menu of the profile page.
$page: The profile page data.
FieldDescription
$tab_menu['name']Required - Name of the menu item.
$tab_menu['type']Required - value is "tab".
$tab_menu['path']Required - Link of the menu item.
Example(usage):
modules/test/test.hook.php
function test_page_menu(&$tab_menu,$page) {
	$tab_menu[] = array(
		'name'=>'Test',
		'type'=>'tab',
		'path'=>'test/page/'.$page['id']
		);
}
	
Back to Top

hook_page_cache()

Note: This hook applys to Jcow Pro only.
Setup a caching rule.
Returns: The returned value goes to cache controller.
Parameters:
$parr: Current Path array.
$page: Current page number (1,2,3,..).
$client: Current session user.
Returned array
FieldDescription
keyRequired - Unique key of the page.
liveOptional - Cache live time (hours).
Example(usage):
modules/test/test.hook.php
function test_page_cache($parr, $page = 1, $client=array()) {
	if ($parr[0] == 'home' && !$client['id']) {
		return array(
			'key'=>'cache_page_home',
			'live'=>2
			);
	}
}
	
Back to Top


Return to menu