Jump to:

5102 Posts in 1520 Topics by 1116 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: 2382 Views
  • dswnz
    Avatar
    Community Member
    9 Posts

    Re: New Admin Module Link to this post

    Here's the CategoryAdmin class using the Panel Model Admin

    class CategoryAdmin extends PanelModelAdmin {

    public static $managed_models = array(
    'Category',
    'Article',
    );
    static $menu_title = 'Category Admin';
    static $url_segment = 'cat_admin';

    function init() {
    parent::init();

    Requirements::block('sapphire/thirdparty/jquery-ui-themes/base/jquery-ui-1.8rc3.custom.css');

    Requirements::css('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css');
    Requirements::javascript('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js');

    $this->addPanel('CategoryPanel', new CategoryMenuPanel('Category', 'open', array('Category' => array('Article'))));
    }
    }

  • Martijn
    Avatar
    Community Member
    270 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
    270 Posts

    Re: New Admin Module Link to this post

    I added the module in a repo:

    http://svn.axyrmedia.com/

  • Tonyair
    Avatar
    Community Member
    81 Posts

    Re: New Admin Module Link to this post

    Requirements isn't working for getCMSFields =(
    class Product:

       public function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->removeByName('Content');
          $fields->addFieldToTab('Root.Main', new MyCustomField('Content'));

          return $fields;
       }


    But if u add them to ProductsAdmin::init() works fine.

  • Martijn
    Avatar
    Community Member
    270 Posts

    Re: New Admin Module Link to this post

    Can you post your code with the Requirements?

    This does work for me:

    function getCMSFields(){
          $f = parent::getCMSFields();
          Requirements::javascript('articles/javascript/articles.js');
          return $f;
       }

  • Tonyair
    Avatar
    Community Member
    81 Posts

    Re: New Admin Module Link to this post

    class CkEditField extends HtmlEditorField {
       public static function include_js($name) {
          Requirements::block('sapphire/thirdparty/tinymce/tiny_mce_src.js'); // <-- don't work
          Requirements::javascript('mysite/ckeditor/ckeditor.js'); // <-- don't work
       }
       function Field() {
          ...
          Requirements::customScript($CKEditor->generateJS(), 'CkEditorConfig'); // <-- don't work
          return $CKEditor->editor($this->name, $value->getContent()); // <-- that's string returned and included
       }
       public function __construct($name, $title = null, $rows = 30, $cols = 20, $value = '', $form = null) {
          parent::__construct($name, $title, $rows, $cols, $value, $form);
          
          $this->include_js($name);
       }
    ...
    }

  • Martijn
    Avatar
    Community Member
    270 Posts

    Re: New Admin Module Link to this post

    And this works in ModelAdmin?

  • Tonyair
    Avatar
    Community Member
    81 Posts

    Re: New Admin Module Link to this post

    It works in Content and popup window, but in PanelAdmin u have to add it manually and of course i have changed JS to replace tinymce.

    Also that thing isn't working http://www.silverstripe.org/general-questions/show/292626?showPost=292632
    So i think something wrong with PanelAdmin's parsing fields functions

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