Code: Select all
<!-- INCLUDEJS 'template/somefile.js' -->
This would have the advantage of reducing the number of conditionals in the header and footer for JavaScript files that are only used on some pages (such as editor.js).
Code: Select all
<!-- INCLUDEJS 'template/somefile.js' -->
Code: Select all
<!-- INCLUDEJS test.js -->
Code: Select all
<!-- DEFINE $TEST = 'test.js' -->
<!-- INCLUDEJS {$TEST} -->
+1Arty wrote:Test implementation: https://github.com/cyberalien/phpbb3/tr ... /includejs
It also includes second test style: progreen, that inherits from prosilver.
Implemented instructions:This will locate file test.js and append code for it to variable {SCRIPTS}. If file is not found, locator returns url to where file is supposed to be in current style.Code: Select all
<!-- INCLUDEJS test.js -->
Then in overall_footer.html after jQuery I've added variable {SCRIPTS}
It also works with template variables, like this:In cases like this files are located dynamically during template display, so its a bit lower than hard coded file names.Code: Select all
<!-- DEFINE $TEST = 'test.js' --> <!-- INCLUDEJS {$TEST} -->
In order to implement that, I had to add some other functionality that might be useful for other modifications:
- $template->context->append_var(var, value) - append to template variable (maybe add template->append_var for it too?)
- $template->locate(file, is_template) - finds file, returns file name relative to phpBB root directory. If second parameter is true, $file is relative to template directory, if false, $file is relative to style directory.
Yesbrunoais wrote:Looks good. Does that work among the template inheritance RFC?
I'm a speed freak and hate when things take longer as they should.callumacrae wrote:You and performance >_<