Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Associating a javascript file to each page, and not in Page.php or template

Go to End

2 Posts   6231 Views


Community Member, 64 Posts

7 December 2008 at 11:01am

Edited: 07/12/2008 11:02am

I know how to include a JavaScript file in Page.php, and in the template, but what this loads the javascript regardless if you use it or not.

I was wondering if there is a way to associate a javascript file to each of the pages, so that it is loaded when called, or needed.

The admin content editing area cleans out <script> put in the html code, is there a way to leave the <script> code in?



Community Member, 64 Posts

7 December 2008 at 10:02pm

I have found a solution to this problem.

The solution is to modify cms/javascript/tinymce.template.js and a line in:

valid_elements : (near line 43)

to allow <script> in your TinyMCE HTML

For more detail please check out this link:

This way, I can include the <script> to the HTML, to only the page I want.