Jcow Documentation>>
Hook file is not required by a module.
Example:
hook_boot() in test module:
modules/test/test.hook.php
Back to Top
Returns: None
Parameters: None. Example:
modules/test/test.hook.php
Back to Top
Returns: Returned content will be written to $header
Parameters: None. Example:
modules/test/test.hook.php
Back to Top
Returns: Returned content will be written to $footer
Parameters: None. Example:
modules/test/test.hook.php
Back to Top
Returns: Returned content will be written to the $widgets
Parameters:
&$widgets: An array of user widgets.
Example:
modules/test/test.hook.php
Back to Top
Returns: None.
Parameters:
&$tab_menu: Current Tab menu of the profile page.
$page: The profile page data.
Example(usage):
modules/test/test.hook.php
Back to Top
Returns: None.
Parameters:
&$tab_menu: Current Tab menu of the profile page.
$page: The profile page data.
Example(usage):
modules/test/test.hook.php
Back to Top
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
Example(usage):
modules/test/test.hook.php
Back to Top
Jcow Hooks API
- How to develop hooks
- hook_boot()
- hook_header()
- hook_footer()
- hook_widget()
- hook_u_menu()
- hook_page_menu()
- hook_page_cache()
How to develop hooks
Hook functions are written to a PHP file named YOUR_MODULE_NAME.hook.phpHook file is not required by a module.
Example:
hook_boot() in test module:
modules/test/test.hook.php
function test_boot() { // do something here }
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 }
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; }
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; }
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'; }
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.
Field | Description |
---|---|
$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. |
modules/test/test.hook.php
function test_u_menu(&$tab_menu,$page) { $tab_menu[] = array( 'name'=>'Test', 'type'=>'tab', 'path'=>'test/profile/'.$page['id'] ); }
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.
Field | Description |
---|---|
$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. |
modules/test/test.hook.php
function test_page_menu(&$tab_menu,$page) { $tab_menu[] = array( 'name'=>'Test', 'type'=>'tab', 'path'=>'test/page/'.$page['id'] ); }
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
Field | Description |
---|---|
key | Required - Unique key of the page. |
live | Optional - Cache live time (hours). |
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 ); } }