5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1090 Views |
-
Inheriting CMSMain

26 August 2009 at 11:59pm
Hello,
I want to add some further plugins to TinyMCE and some methods to CMSMain. For this reason I've created a class that inherits directly from CMSMain and overwrites some methods.
Unfortunately when the user enters the url /admin the CMSMain object is still called. I've added following command to _config.php so that SilverStripe is calling the MyMain object:Director::addRules(60, array(
'admin/cms//$Action/$ID/$OtherID' => 'MyMain',
));That does not work. Am I missing something???
-
Re: Inheriting CMSMain

27 August 2009 at 1:01am
Hm strange indeed. I never tried that.
Did you do a dev/build? Otherwise SilverStripe probably won't find the appropriate class (MyMain) -
Re: Inheriting CMSMain

27 August 2009 at 5:26am
Hi there,
/dev/build doesn't help. MyMain is recognized since a rule like '/testmain' works perfectly.
Greetings!
-
Re: Inheriting CMSMain

28 September 2009 at 1:06am
I am currently in the middle of doing this, and quite frankly its a pain in the ass!
So far I have added this to my dashboard modules _config.php file:
Director::addRules(50, array(
'admin/dashboard' => 'DashboardAdmin'
));CMSMain::$url_segment = 'cms';
CMSMenu::replace_menu_item('CMSMain', 'Site Content', 'admin/cms/', null, 10);
And added this class to extend the CMS' main menu:
class DashboardAdmin extends LeftAndMain {
static $url_segment = '';
static $menu_title = 'Dashboard';
static $menu_priority = 99;
static $url_priority = 41;/**
* Initialisation method called before accessing any functionality that RandomLinksAdmin has to offer
*/
public function init() {
parent::init();
Requirements::css('dashboard/css/Dashboard.css');
Requirements::customScript(file_get_contents(Director::baseFolder() . '/dashboard/javascript/Dashboard.js'));
}
...}
?>
The most important lines are:
static $url_segment = '';
static $url_priority = 41;These basically tell Silverstripe that your new class has a higher priority than CMSMain. Please note though that url_priority can't exceed 49!
Doing this overrides the default behaviour of the CMS, but for me has caused a load of new isses, so I am now trying to extend CMSMain to fix them, I will post back when I get a result
Mo
-
Re: Inheriting CMSMain

28 September 2009 at 1:29am
Not sure if you have read this, but it has some handy snippets: http://doc.silverstripe.com/doku.php?id=cmsmain
| 1090 Views | ||
|
Page:
1
|
Go to Top |



