2

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 1

6

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Nice tip, one note from PHPdoc of VH: $addJsFile Custom JavaScript file to be loaded (deprecated, use $includeJsFiles)
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.