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.

Archive /

Our old forums are still available as a read-only archive.

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

ModelAdmin - patch and suggestions


Go to End


2 Posts   1148 Views

Avatar
Hamish

Community Member, 712 Posts

20 September 2008 at 12:13pm

Edited: 20/09/2008 12:15pm

HI all,

@coredevs - I've submitted a patch (2826) for ModelAdmin but I couldn't set the milestone/version to 2.3. Could someone change it?

The purpose of the patch is to fix a css issue with subclassed ModelAdmin's, resolve the issue around the Link() method and to suggest a couple of further improvements.

At the moment, it looks like you wanted to interrogate director for the correct URL, but it occurred to me that in your _config file, you have to send directives to Director and LeftAndMain to set up your controllers etc.

It would be preferable to encapsulate that logic inside ModelAdmin itself. For example, instead of:

Director::addRules(100, array(
	'admin/myadmin' => 'MyAdmin',
));
LeftAndMain::add_menu_item(
	'myadmin',
	_t('LeftAndMain.MYADMIN', 'MYADMIN'),
	'admin/myadmin/',
	'MyAdmin'
);

you would do:

MyAdmin::addToCMS();

Since you would keep the panel name and url inside of MyAdmin, and it already knows what class it is, the only other functionality that you might want is the ability to move it around the menu and/or set director priorities.

Consequently, since it is aware of it's url you can return Link() in a CMSMain friendly form.

It's a small change, but it solves the Link() issue, it provides a friendly way to add menu items and director instructions and looks nicer all round.

Thanks!

Avatar
Willr

Forum Moderator, 5523 Posts

22 September 2008 at 8:37pm

Hamish - fixed the ticket for you. As for the patch, it seems logical to me but hey I'm not the one integrating the patches!