Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Add JavaScript to Administrative Area

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

Page: 1
Go to End
Author Topic: 1775 Views
  • Deklin
    Avatar
    Community Member
    16 Posts

    Add JavaScript to Administrative Area Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Add JavaScript to Administrative Area Link to this post

    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.

  • Deklin
    Avatar
    Community Member
    16 Posts

    Re: Add JavaScript to Administrative Area Link to this post

    Thanks!

  • Lukin
    Avatar
    Community Member
    41 Posts

    Re: Add JavaScript to Administrative Area Link to this post

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

    1775 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.