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

Overriding CMSMain url_segment


Go to End


2 Posts   1885 Views

Avatar
Mo

Community Member, 541 Posts

2 October 2009 at 2:25am

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

Avatar
Ingo

Forum Moderator, 801 Posts

3 October 2009 at 10:05am

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.