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

New Admin Module


Go to End


14 Posts   5450 Views

Avatar
webair

Community Member, 8 Posts

16 September 2010 at 4:21am

Edited: 16/09/2010 4:23am

Hi

I have to create a Admin Module for one of my customers, hopefully when i am finished i also can publish it on silverstripe.org ;).

But i have some problems finding the right way to create the module, because its not that good documented, or the documentation is a little out of date http://doc.silverstripe.org/private:tutorial:creating-a-module. Also i am working with the newest release of silverstripe and read about the changes that were made, as specially in the javascript section.

So before i start, i would like to know if there is a example of code, which shows me how to create a admin module, with a seperate section like the files/media module. Which module would be best to look at? So i can see how to create a module with jquery instead of prototype - so that i am future safe ;)

thanks and best regards

webair

Avatar
swaiba

Forum Moderator, 1899 Posts

16 September 2010 at 5:01am

I'd like to second this, I posted here a couple of weeks ago asking for help with essentially a custom LeftAndMain - with no response.

Every time I need to do something that doesn't fit into the site tree or ModelAdmin my heart sinks because there is basically nothing (except trying to emulate an existing, uncommented, unclear module - naming no names) - and I have failed at this.

If there is anything that explains something like this or goes into any detail on how to customise LeftAndMain I would be very grateful for too.

Barry

Avatar
Martijn

Community Member, 271 Posts

16 September 2010 at 5:44am

Edited: 16/09/2010 5:49am

I created an Extended ModelAdmin which allows the use of Panels instead of the default ModelAdmin sidebar.

I use it on a few simple projects now and it seems to work quite solid.

See this trhead for more info:

http://groups.google.com/group/silverstripe-dev/browse_thread/thread/e38c4f36a0afc156

In this post you can find two download links, one for the PanelModelAdmin and one for a demo implementation.

http://groups.google.com/group/silverstripe-dev/msg/1c2c6b4abd9ace40?

See this slides for what it does:

http://www.slideshare.net/marvanni/panelmodeladmin-example
http://www.slideshare.net/marvanni/panel-modeladmin

Its not extensively tested yet, and it still contains a lot of duplicate code, but it should point you to the right direction and it makes creating a custom LeftAndMain much easier then extending LeftAndMain directly.

Let me know what you think of it.

Edit: Note that some code examples in the slides are changed. See the ProductAdmin example for how it works at the moment...

Avatar
swaiba

Forum Moderator, 1899 Posts

17 September 2010 at 1:08am

Thanks Martijn - I'll check that out. I'm going to prepare my attempts as well and maybe get a tutorial together - best way to learn is to be able to teach it!

Barry

Avatar
Martijn

Community Member, 271 Posts

17 September 2010 at 6:12pm

Edited: 17/09/2010 6:41pm

You need to set this in Article:

static $admin_parent_class = 'Category';

Indeed, this might be an idea to set that in the MenuPanel array. (Not sure if this will work after saving an item at the moment...)

I will take a look at the ajaxstring this weekend... (see Edit below)

Note that this is still just a proof of concept, and there are some known issues with buttons showing up on wrong places :).

But besides that all should work as ModelAdmin does.

Edit:

Your right. The function getResultsAssembly in CategoryMenuPanel is missing a & at r79. thanks:

function getResultAssembly($sgn){
		$columns = $sgn->stat('summary_fields');
		$search = '?';
		if($columns){
			foreach($columns as $k => $v){
				$search	.= 'ResultAssembly['.$k.']='.$k.'&';
			}
		} else {
			$field = $sgn->hasDatabaseField('Title') ? 'Title' : 'Name';
			$search	.= 'ResultAssembly['.$field.']='.$field.'&';
		}
		return $search;
	}

Avatar
Martijn

Community Member, 271 Posts

21 September 2010 at 10:05am

Can you pastie your code?

Yes I will do, but it still needs some refinement...

Avatar
Martijn

Community Member, 271 Posts

23 September 2010 at 6:25am

Yes no I remember :)

At this moment you have to add CategoryID to the searchable fields as well...

I'm trying to fix this within PanelModelAdmin, but this is not easy...

add this as well to Article.php

static $searchable_fields = array(
		'Title',
		'CategoryID'
	);

Avatar
Martijn

Community Member, 271 Posts

23 September 2010 at 6:57am

I added the module in a repo:

http://svn.axyrmedia.com/

Go to Top