New Template Commands in 3.1

This article lists new template commands available in phpBB 3.1

INCLUDEJS
This command queues external javascript file for inclusion in footer.

Syntax:

Path to .js file should be relative to style's template directory. Function can accept template variables, as displayed in sample code above.

Unlike using &lt;script&gt; tag, this command will put your script in the footer of the page between the inclusion of jQuery and &lt;/body&gt;, allowing you to use jQuery in your script. It will also check styles tree for location of your file, which works similar to template inheritance. Scripts will be outputted in the same order as they were parsed via INCLUDEJS.

Example (full sample page, so you could see where code will appear): header stuff here

Some content

footer code here jQuery is included here This will result in following HTML output: header stuff here some content footer code here jQuery is included here    Script tag that was included via INCLUDEJS was moved to footer, the same order as they were in the markup, before &lt;/body&gt; and path was changed to correct relative path to the .js file.

EVENT
This command is for event hooks.

Syntax: It will include code from overall_header_head.html template from current style and all extensions, allowing extensions to insert code without editing template files.

In extensions you should place such templates in directory ext/your_extension_vendor_name/package_name/styles/all/template If you want to include different templates for different styles, in addition to styles/all/ create directories for those styles, such as ext/your_extension_vendor_name/package_name/styles/prosilver/template. Those directories take priority when template is included, with "all" being lowest priority.

Only one template file per extension is included, so having template in ext/your_extension_vendor_name/package_name/styles/all/template and ext/your_extension_vendor_name/package_name/styles/prosilver/template will not include it twice.

INCLUDECSS
This command queues external CSS files for inclusion in header.

Syntax:

Path to .css file should be relative to style's template directory. Function can accept template variables, as displayed in sample code above.

Unlike using &lt;link&gt; tag, this command will put your CSS links in the header of the page before the closing head tag. It will also check styles tree for location of your file, which works similar to template inheritance. CSS files will be outputted in the same order as they were parsed via INCLUDECSS.

Example (used inside of the template event &lt;!-- EVENT overall_header_head_append --&gt;): header stuff here

Some additional content This will result in following HTML output: header stuff here Some additional content   CSS files that were included via INCLUDECSS were placed in header, the same order as they were in the markup, before &lt;/head&gt; and path was changed to correct relative path to the .css file.