Development Wiki

New Template Commands in 3.1

From phpBB Development Wiki

Revision as of 13:16, 8 August 2014 by Vse (Talk | contribs)

This article lists new template commands available in phpBB 3.1


This command queues external javascript file for inclusion in footer.

<!-- INCLUDEJS file.js -->

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

Unlike using <script> tag, this command will put your script in the footer of the page between the inclusion of jQuery and </body>, 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):
<!-- overall_header.html -->
	header stuff here
	<!-- INCLUDEJS custom1.js -->
<!-- end of overall_header.html -->
<!-- custom template -->
	Some content
	<!-- INCLUDEJS custom2.js -->
<!-- end of custom template -->
<!-- overall_footer.html -->
	<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/custom3.js -->
	footer code here
	jQuery is included here
<!-- end of overall_footer.html -->
This will result in following HTML output:
header stuff here
some content
footer code here
jQuery is included here
<script src="./styles/prosilver/template/custom1.js"></script>
<script src="./styles/prosilver/template/custom2.js"></script>
<script src="./assets/javascript/custom3.js"></script>

Script tag that was included via INCLUDEJS was moved to footer, the same order as they were in the markup, before </body> and path was changed to correct relative path to the .js file.


This command is for event hooks.

<!-- INCLUDEJS @vendor_package/file.js -->
<!-- EVENT acp_overall_header_head_append -->

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.