Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Overriding CMSMain url_segment

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

Page: 1
Go to End
Author Topic: 1296 Views
  • Mo
    Avatar
    Community Member
    504 Posts

    Overriding CMSMain url_segment Link to this post

    Hi all,

    I have overwritten the url_segment of CMSMain so that it points to 'cms' rather than ''. For the most part this seems to work, but I am having loads of issues with the AJAX.

    I have overwritten the below using my own custom javascript:

    // Overwrite main Ajax scripts for site tree
    if(typeof SiteTreeHandlers == 'undefined') SiteTreeHandlers = {};
    SiteTreeHandlers.parentChanged_url   = 'admin/cms/ajaxupdateparent';
    SiteTreeHandlers.orderChanged_url   = 'admin/cms/ajaxupdatesort';
    SiteTreeHandlers.loadPage_url      = 'admin/cms/getitem';
    SiteTreeHandlers.loadTree_url      = 'admin/cms/getsubtree';

    But I have also had to copy large chunks of Prototype code so that I can alter some of the URL's that are hard coded into it, for example SideReports.prototype in cms/javascript/sidereports/

    Is this the only way I can change these url's?

    Also, for some reason, my custom javascript file is also being loaded into SecurityAdmin.php as well as just CMSMain.php. Anyone got an idea why?

    I am embedding my javascript using:

    class DsCMSMain extends Extension {
       public function __construct(){
          Requirements::customScript(file_get_contents(Director::baseFolder() . '/dashboard/javascript/DsCMSMain_left.js'));
       }
    }

    Which I use to extend CMSMain using Object::add_extension();

    Any help would be brilliant!!

    Cheers,

    Mo

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Overriding CMSMain url_segment Link to this post

    I dont think there's a less hacky way for now... we'll have less hardcoding in the javascript with the 2.4 release, where nearly all actions simply send off forms (which have the form action generated from the CMSMain controller). This means you can simply overload the Link() method in CMSMain to change the URL.

    1296 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.