Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Extending the Admin CMS - Dealers Tab

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2
Go to End
Author Topic: 2040 Views
  • borriej
    Avatar
    Community Member
    267 Posts

    Extending the Admin CMS - Dealers Tab Link to this post

    Hello,

    I want to extend the Admin part of the CMS because I want to create a dealer Locator.

    I've made a sketch on how it must look:

    Specs:
    - Extra tab in CMS: Dealers (list must contain all the dealers in the dataBase)
    - With the icons you must be able to delete or modify an entry
    - With the add button you must be able to add an entry

    - Variables in each row/entry:
    naam    varchar(100)          
    adres    varchar(100)          
    postcode    varchar(6)          
    plaats    varchar(100)          
    telefoon    varchar(25)          
    website    varchar(150)

    Tutorial
    I already followed some tutorials about this subject, but they are not sufficient. When I tried the tutorials I got a white screen..
    followed:
    - http://doc.silverstripe.org/modeladmin?s[]=modeladmin
    and:
    - http://doc.silverstripe.org/dataobject#customizing_scaffolded_fields

    Also done read this presentation:
    - http://www.slideshare.net/chillu/modeladmin-in-silverstripe-23
    and downloaded the files, see page 28, and click the link.

    But those files didnt work for me with SilverStripe 2.3.7!
    Combined the files with my files online, but when: dev/build?flush=1
    I only go a white screen..

    !) Please help me, where do I start to build this feature?

    Thank you!

  • borriej
    Avatar
    Community Member
    267 Posts
  • borriej
    Avatar
    Community Member
    267 Posts
  • martimiz
    Avatar
    Forum Moderator
    1068 Posts

    Re: Extending the Admin CMS - Dealers Tab Link to this post

    In a hurry?
    This should get you going: it will create a Dealer Locator menu item in the CMS, where you can add Dealers using the ModelAdmin functionality. Just curious - why not just use a ComplexTableField (or DataObjectManager if you wish) on some Dealer Page (unless you're planning to add a large amount of dealers, that is)?

    Dealer.php

    <?php
    class Dealer extends DataObject {

       static $db = array(
          'naam' => 'Varchar(100)',
          'adres' => 'Varchar(100)',
          'postcode' => 'Varchar(6)',
          'plaats' => 'Varchar(100)',
          'telefoon' => 'Varchar(25)',
          'website' => 'Varchar(150)',
       );

       static $searchable_fields = array(
          'naam',
          'adres',
          'postcode',
          'plaats'
       );

       static $summary_fields = array(
          'naam',
          'adres',
          'postcode',
          'plaats'
       );
    }
    ?>

    DealerAdmin.php

    <?php
    class DealerAdmin extends ModelAdmin {

       public static $managed_models = array(
          'Dealer'
       );

       static $url_segment = 'dealerlocator';
       static $menu_title = 'Dealer Locator';
    }
    ?>


    Do a /dev/build/?flush=1 after

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Extending the Admin CMS - Dealers Tab Link to this post

    I pressed the button twice but yes I'm in a hurry I really like SilverStripe and want to learn as fast a possible ;)

    Thank you for the code I will try it in a second! Thank you.

    There will be like 400 dealers, therefor a different section would be nice?
    I already have a database with 400 dealers in it, so I hope SilverStripe will be able to add 'records/rows' in this structure.

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Extending the Admin CMS - Dealers Tab Link to this post

    Ok SUPER it works How do I add a pencil-icon behind every entry so I can modify it?

  • martimiz
    Avatar
    Forum Moderator
    1068 Posts

    Re: Extending the Admin CMS - Dealers Tab Link to this post

    You can't (unless you want to go through a whole lot of trouble) and you don't have to. Just click on the items you added to open the popup...

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Extending the Admin CMS - Dealers Tab Link to this post

    I've magaged to change all my old entry's to the new database format.

    So changed the record format from:

    INSERT INTO `Dealer` (`ID`, `naam`, `adres`, `postcode`, `plaats`, `telefoon`, `website`)

    into:

    INSERT INTO `Dealer` (`ID`, `ClassName`, `Created`, `LastEdited`, `naam`, `adres`, `postcode`, `plaats`, `telefoon`, `website`) VALUES

    and it works

    But I do like to be able to make changes to each record in SilverStripe, now it is not possible. When I click a dealer, I can type new text into a field, but i can't hit the save button.

    Is it possible to add this?

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