Jump to:

5121 Posts in 1527 Topics by 1119 members

Customising the CMS

SilverStripe Forums » Customising the CMS » New Admin Module

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3
Go to End
Author Topic: 2432 Views
  • webair
    Avatar
    Community Member
    8 Posts

    New Admin Module Link to this post

    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

  • swaiba
    Avatar
    Forum Moderator
    1689 Posts

    Re: New Admin Module Link to this post

    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

  • Martijn
    Avatar
    Community Member
    270 Posts

    Re: New Admin Module Link to this post

    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...

  • swaiba
    Avatar
    Forum Moderator
    1689 Posts

    Re: New Admin Module Link to this post

    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

  • dswnz
    Avatar
    Community Member
    9 Posts

    Re: New Admin Module Link to this post

    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?

  • Martijn
    Avatar
    Community Member
    270 Posts

    Re: New Admin Module Link to this post

    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;
       }

  • dswnz
    Avatar
    Community Member
    9 Posts

    Re: New Admin Module Link to this post

    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.

  • Martijn
    Avatar
    Community Member
    270 Posts

    Re: New Admin Module Link to this post

    Can you pastie your code?

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

    2432 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.