From 4225ccc66e45074e2daceb5fa5f25bfd55ec0c88 Mon Sep 17 00:00:00 2001 From: "gerv%gerv.net" <> Date: Mon, 19 Jan 2004 08:25:16 +0000 Subject: Bug 230742 - document new 'hooks' mechanism. This is my take on Myk's text - probably still needs further polish. --- docs/xml/customization.xml | 191 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) (limited to 'docs/xml') diff --git a/docs/xml/customization.xml b/docs/xml/customization.xml index 2e3306f88..a9005665e 100644 --- a/docs/xml/customization.xml +++ b/docs/xml/customization.xml @@ -305,6 +305,197 @@ +
+ Template Hooks + + + Template hooks are a way for customisers or Bugzilla extensions to insert + code into the standard Bugzilla templates without modifying them. + The hooks mechanism defines an API for extending the + standard templates with a clean separation of code. + This makes the changes less tied to specific versions of + Bugzilla, and reduces merge conflicts, making + upgrading a modified Bugzilla installation easier. + + + + A template hook is just an named place in a standard template file. + When Bugzilla reaches this position, it checks whether there are any + extension template files for that hook. If so, it processes them. Each + hook has a directory of its own in the Bugzilla template directory tree. + Hooking a template file on to a specific hook is as + simple as putting the file into that hook's directory. + + + + To use hooks to extend a Bugzilla template, first make sure there is a + hook at the appropriate place within the template you want to extend. + Hooks appear in the default Bugzilla templates as a single template + directive in the format + [% Hook.process("<name>") %], where + <name> + is the unique (within that template) name of the hook. + + + + If you aren't sure which template you want to extend or just want to + browse the available hooks, either use your favorite multi-file search + tool (e.g. grep) to search the standard templates for occurrences of + "Hook.process" or browse the directory tree in + $BUGZILLA_HOME/template/en/extension/hook/, + which contains a directory for each hook. Each hook's directory + is located as follows: + + + + $BUGZILLA_HOME/template/en/extension/hook/<path-to-standard-template>/<standard-template-name>/<hook-name>/ + + + + If there is no hook in the appropriate place within the Bugzilla + template you want to extend, + file + a bug requesting one, specifying: + + + + the template for which you are requesting a hook; + + + where in the template you would like the hook to be placed (line + number/position for latest version of template in CVS or description of + location); + + the purpose of the hook; + a link to information about your extension, if any. + + + + The Bugzilla reviewers will promptly review each hook request, + name the hook, + add it to the template and check the new version into CVS, and add the + corresponding directory to + $BUGZILLA_HOME/template/en/extension/hook/. + + + + You may optionally attach a patch to the bug which implements the hook + and check it in yourself after receiving approval from a Bugzilla + reviewer. The developers may suggest changes to the location of the + hook based on their analysis of your needs or so the hook can satisfy + the needs of multiple extensions, but the process of getting hooks + approved and checked in is not as stringent as the process for general + changes to Bugzilla, and any extension, whether released or still in + development, can have hooks added to meet their needs. + + + + After making sure the hook you need exists (or getting it added if not), + add your extension template to the directory within the Bugzilla + directory tree corresponding to the hook. + + + + That's it! Now, when the standard template containing the hook is + processed, your extension template will be processed at the point + where the hook appears. + + + + For example, let's say you have an extension named Projman that adds + project management capabilities to Bugzilla. Projman has an + administration interface edit-projects.cgi, + and you want to + add a link to it into the navigation bar at the bottom of every Bugzilla + page for those users who are authorized to administer projects. + + + + The navigation bar is generated by the template file + useful-links.html.tmpl, which is located in the + global/ subdirectory on the standard Bugzilla + template path + $BUGZILLA_HOME/template/en/default/. + Looking in useful-links.html.tmpl, you find the + following + hook at the end of the list of standard Bugzilla administration links: + + + ... + [% ', <a href="editkeywords.cgi">keywords</a>' + IF user.groups.editkeywords %] + [% Hook.process("edit") %] +... + + + The corresponding directory for this hook is + $BUGZILLA_HOME/template/en/extension/hook/global/useful-links.html.tmpl/edit/. + + + + You put a template named + projman-edit-projects.html.tmpl + into that directory with the following content: + + + [% ', <a href="edit-projects.cgi">projects</a>' IF user.groups.projman_admins %] + + + Voila! The link now appears after the other administration links in the + navigation bar for users in the projman_admins group. + + + + Notes: + + + + + + You may want to prefix your extension templates names with + the name of your extension, e.g. + projman-foo.html.tmpl, + so there is no chance of a conflict with the names of + templates installed by other extensions. + + + + + + If your extension includes entirely new templates in addition to + extensions of standard templates, it should install those new templates + into an extension-specific subdirectory of the + $BUGZILLA_HOME/template/en/extension/ + directory. + The extension/ directory, like the + default/ + and custom/ directories, is part of the template + search path, so putting templates there enables them to be found by + the template processor. + + + + The template processor looks for templates first in the + custom/ directory (i.e. templates added by the + specific installation), then in the extension/ + directory (i.e. templates added by extensions), and finally in the + default/ directory, for the standard Bugzilla + templates. + Thus extension templates can override standard templates, but + installation-specific templates override both. + + + + Note that overriding standard templates gives you great power but + also makes + upgrading an installation harder. As with custom templates, we + recommend using this functionality sparingly and only when absolutely + necessary. + + + +
+
Customizing Who Can Change What -- cgit v1.2.3-24-g4f1b