From ff0a4a3124c2eb7f2b5bb18ba756844d51c52b51 Mon Sep 17 00:00:00 2001 From: Pascal Deklerck Date: Thu, 14 Jun 2018 15:31:38 +0200 Subject: [PATCH] Added PHP part of JavaScript hooks to Addons.md doc --- doc/Addons.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/doc/Addons.md b/doc/Addons.md index b3f42b892..22b34fa62 100644 --- a/doc/Addons.md +++ b/doc/Addons.md @@ -71,6 +71,29 @@ Remember to declare it with '&' if you wish to alter it. JavaScript addon hooks --- +#### PHP part +Make sure your JavaScript addon file (addon/*addon_name*/*addon_name*.js) is listed in the document response. + +In your addon install function, add: + + Addon::registerHook('template_vars', 'addon//.php', '_template_vars'); + +In your addon uninstall function, add: + + Addon::unregisterHook('template_vars', 'addon//.php', '_template_vars'); + +Then, add your addon name to the *addon_hooks* template variable array: + + function _template_vars($a, &$arr) + { + if (!array_key_exists('addon_hooks',$arr['vars'])) + { + $arr['vars']['addon_hooks'] = array(); + } + $arr['vars']['addon_hooks'][] = ""; + } + +#### JavaScript part Register your addon hooks in file 'addon/*addon_name*/*addon_name*.js'. Addon_registerHook(type,hookfnstr);