Mecha CMS

Mecha CMS blog and documentation.

Function Hooks

Updated: Sunday, 07 August 2016

List of the available function hooks.

Related: [article:class-weapon]

Hook Names

Frontend

HookDescription
shield_lot_beforeWill be triggered before lot data extraction.
shield_lot_afterWill be triggered after lot data extraction.
shield_beforeWill be triggered before shield output.
shield_afterWill be triggered after shield output.
chunk_lot_beforeWill be triggered before lot data extraction.
chunk_lot_afterWill be triggered after lot data extraction.
chunk_beforeWill be triggered before chunk output.
chunk_afterWill be triggered after chunk output.
SHIPMENT_REGION_TOPWill be triggered before header content starts loading into the page.
SHIPMENT_REGION_BOTTOMWill be triggered after body content sucessfully loaded into the page.
metaWill be triggered between the page metadata. Use the hook function priority to arrange the position. This hook is embedded in the SHIPMENT_REGION_TOP hook and used to load the default page metadata.
shell_beforeWill be triggered before CSS files start loading into the page.
shell_afterWill be triggered after CSS files sucessfully loaded into the page.
cargo_beforeWill be triggered before body content starts loading into the page.
cargo_afterWill be triggered after body content sucessfully loaded into the page, before the SHIPMENT_REGION_BOTTOM hook action.
sword_beforeWill be triggered before JavaScript files start loading into the page.
sword_afterWill be triggered after JavaScript files sucessfully loaded into the page.
article_footerWill be triggered on your article footer.
page_footerWill be triggered on your page footer.
comment_footerWill be triggered on your comment footer.
comment_form_input_beforeHook to extends more comment form input before the available form inputs.
comment_form_input_afterHook to extends more comment form input after the available form inputs.
comment_form_textarea_beforeHook to extends more comment form textarea before the available form textareas.
comment_form_textarea_afterHook to extends more comment form textarea after the available form textareas.
comment_form_button_beforeHook to extends more comment form button before the available form buttons.
comment_form_button_afterHook to extends more comment form button after the available form buttons.
before_kickWill be triggered before page redirection.

This stage process should be easier for you to understand:

⌚ shield_before
<!DOCTYPE html>
<html>
  <head>
⌚ SHIPMENT_REGION_TOP
⌚ shell_before
    <link href="path/to/file.css" rel="stylesheet">
    <style>
    .foo {color:#ffa500}
    </style>
⌚ shell_after
  </head>
  <body>
⌚ cargo_before
    <div>
      <p>Page contents goes here …</p>
    </div>
⌚ cargo_after
    <p>Another stuff …</p>
⌚ sword_before
    <script src="path/to/file.js"></script>
    <script>_init();</script>
⌚ sword_after
    <p>Another stuff …</p>
⌚ SHIPMENT_REGION_BOTTOM
  </body>
</html>
⌚ shield_after

Backend

Configuration
HookDescription
on_config_updateWill be triggered after configuration update.
Article
HookDescription
on_article_constructWill be triggered after article creation.
on_article_destructWill be triggered after article deletion.
on_article_repairWill be triggered after article update.
on_article_updateWill be triggered after article creation, deletion and update.
Page
HookDescription
on_page_constructWill be triggered after page creation.
on_page_destructWill be triggered after page deletion.
on_page_repairWill be triggered after page update.
on_page_updateWill be triggered after page creation, deletion and update.
Comment
HookDescription
on_comment_constructWill be triggered after comment creation.
on_comment_destructWill be triggered after comment deletion.
on_comment_repairWill be triggered after comment update.
on_comment_updateWill be triggered after comment creation, deletion and update.
on_comment_notify_constructWill be triggered after notification email of new comments sent.
Tag
HookDescription
on_tag_constructWill be triggered after tag creation.
on_tag_destructWill be triggered after tag deletion.
on_tag_repairWill be triggered after tag update.
on_tag_updateWill be triggered after tag creation, deletion and update.
Menu
HookDescription
on_menu_constructWill be triggered after menu creation.
on_menu_destructWill be triggered after menu deletion.
on_menu_repairWill be triggered after menu update.
on_menu_updateWill be triggered after menu creation, deletion and update.
Asset
HookDescription
on_asset_constructWill be triggered after asset creation.
on_asset_destructWill be triggered after asset deletion.
on_asset_repairWill be triggered after asset update.
on_asset_updateWill be triggered after asset creation, deletion and update.
Field
HookDescription
on_field_constructWill be triggered after field creation.
on_field_destructWill be triggered after field deletion.
on_field_repairWill be triggered after field update.
on_field_updateWill be triggered after field creation, deletion and update.
Shortcode
HookDescription
on_shortcode_updateWill be triggered after shortcode update.
Shield
HookDescription
on_shield_constructWill be triggered after shield creation.
on_shield_destructWill be triggered after shield deletion.
on_shield_repairWill be triggered after shield update.
on_shield_updateWill be triggered after shield creation, deletion and update.
Plugin
HookDescription
on_plugin_constructWill be triggered after plugin creation.
on_plugin_destructWill be triggered after plugin deletion.
on_plugin_updateWill be triggered after plugin creation, deletion and update.
on_plugin_mountWill be triggered after plugin install.
on_plugin_ejectWill be triggered after plugin uninstall.
on_plugin_ . md5('folder-name') . _constructWill be triggered after folder-name plugin creation.
on_plugin_ . md5('folder-name') . _destructWill be triggered after folder-name plugin deletion.
on_plugin_ . md5('folder-name') . _updateWill be triggered after folder-name plugin creation, deletion and update.
on_plugin_' . md5('folder-name') . '_mountWill be triggered after folder-name plugin install.
on_plugin_' . md5('folder-name') . '_ejectWill be triggered after folder-name plugin uninstall.
Cache
HookDescription
on_cache_constructWill be triggered after cache creation.
on_cache_destructWill be triggered after cache deletion.
on_cache_repairWill be triggered after cache update.
on_cache_updateWill be triggered after cache creation, deletion and update.
Backup/Restore
HookDescription
on_restore_constructWill be triggered after backup file upload success (when doing a restore).
on_backup_constructWill be triggered after backup package creation.
on_backup_destructWill be triggered after backup package transferred to the user and ready to be downloaded.
Error
HookDescription
on_error_destructWill be triggered after error log file deletion.

Hook Arguments

Most of the function hooks will also bring important data from the action taken:

Weapon::add('on_article_update', function($G, $P) {
    var_dump($G, $P);
    exit;
});

The function above should outputs the article data to the screen immediately after you hit the Update button.

Donation and Email Subscription