I want to use custom JS libraries in my extbase extension. Is it possible to use add_additional footer data api in a backend module controller?
1 Answer
Use a viewhelper in your backend Fluid template:
<f:be.container
addJsFile = "{f:uri.resource(path:'js/script.js')}">
<!-- Content -->
</f:be.container>
UPDATE:
As mentioned by @biesior (thanks!) the method addJsFile is deprecated. Here is an example using the new and recommended be.container viewhelper method includeJsFiles instead. This new function can include multiple JS files instead of just one:
<f:be.container
includeJsFiles = "{0:'{f:uri.resource(path: \'js/script1.js\')}', 1:'{f:uri.resource(path: \'js/script2.js\')}'}" >
<!-- Content -->
</f:be.container>
See the corresponding Fluid viewhelper documentation.
2 Comments
biesior
Nice tip, one note from PHPdoc of VH:
$addJsFile Custom JavaScript file to be loaded (deprecated, use $includeJsFiles)Riccardo De Contardi
according to the documentation the correct syntax for the array should be
includeJsFiles = "{0:'{f:uri.resource(path: \'js/script1.js\')}', 1:'{f:uri.resource(path: \'js/script2.js\')}'}" or am I wrong?