5121 Posts in 1527 Topics by 1119 members
| Go to End | Next > | |
| Author | Topic: | 2432 Views |
-
New Admin Module

16 September 2010 at 4:21am Last edited: 16 September 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
-
Re: New Admin Module

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
-
Re: New Admin Module

16 September 2010 at 5:44am Last edited: 16 September 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-modeladminIts 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...
-
Re: New Admin Module

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
-
Re: New Admin Module

17 September 2010 at 9:15am Last edited: 17 September 2010 9:20am
I've just tried out your module Martijn, Great work.
I have come across some weird issues (might be my code, not sure) but when using the CategoryMenuPanel, it doesn't respect the child->parent relationship.Here's my code for using the panel
$this->addPanel(
'CategoryPanel',
new CategoryMenuPanel(
'Categories',
'open',
array( 'Category' => array('Article') )
)
);The problem is that all Articles are being displayed for each Category, rather than just the category they're associated to?
I noticed that the ajax query string was missing the '&' as well when doing the search.When running the search it was querying:
"?ResultAssembly[Title]=TitleCategory__ID=33"
instead of "?ResultAssembly[Title]=Title&Category__ID=33"To fix this I did the following:
// Updated CategoryMenuPanel.php line 35 from :
$link = Controller::join_links("admin",$this->url_segment,$child,"SearchForm") . $childSearch
// To
$link = Controller::join_links("admin",$this->url_segment,$child,"SearchForm") . $childSearch . '&'Didn't seem to solve my problem though. Any Ideas?
-
Re: New Admin Module

17 September 2010 at 6:12pm Last edited: 17 September 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;
} -
Re: New Admin Module

20 September 2010 at 12:56pm Last edited: 20 September 2010 12:56pm
Unfortunately setting the $admin_parent_class didn't seem to solve my problem
I might have to dig around and see what is causing this.Are you planning on putting PanelModelAdmin up on Github or something of the like. Even as it is, I personally think the community would benefit from it.
-
Re: New Admin Module

21 September 2010 at 10:05am
Can you pastie your code?
Yes I will do, but it still needs some refinement...
| 2432 Views | ||
| Go to Top | Next > |



