Jump to:

5539 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » New Admin Module

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 3119 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
    1788 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
    271 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
    1788 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

  • Martijn
    Avatar
    Community Member
    271 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;
       }

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: New Admin Module Link to this post

    Can you pastie your code?

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

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: New Admin Module Link to this post

    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'
       );

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: New Admin Module Link to this post

    I added the module in a repo:

    http://svn.axyrmedia.com/

    3119 Views
Page: 1 2
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.