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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Add JavaScript to Administrative Area


Go to End


4 Posts   3482 Views

Avatar
Deklin

Community Member, 16 Posts

12 July 2010 at 10:54pm

This code adds my custom JavaScript to BOTH the administrative area AND the public website:

// from mysite/code/page.php
function getCMSFields() {
Requirements::javascript( 'mysite/javascript/custumL.js ' );
}

I only want to add the JavaScript to the administrative area. It should NOT be loaded on the public website.

Avatar
Willr

Forum Moderator, 5523 Posts

13 July 2010 at 4:36pm

Use this in your _config file

LeftAndMain::require_javascript('mysite/javascript/custumL.js');

LeftAndMain is the class which handles the CMS. Though unless you call getCMSFields() on the front end of the site it shouldn't include any JS from that function.

Avatar
Deklin

Community Member, 16 Posts

14 July 2010 at 9:24am

Thanks!

Avatar
Lukin

Community Member, 56 Posts

28 February 2012 at 3:26am

Is this still working in 2.46?
I tried it without success....