Jump to:

796 Posts in 409 Topics by 304 members


SilverStripe Forums » Widgets » Using a DataObjectManager in widget

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 766 Views
  • Ronaldo71
    Community Member
    10 Posts

    Using a DataObjectManager in widget Link to this post


    I'm trying to convert the Nivo Slider extension into a widget, because I don't like it to mix up page types just for something I'd like to use on multiple page types. The original Nivo Slider extension can be found here:

    Anyway, as can be seen in the attached screenshot, it all seems to work, except for the edit link of an item.
    The edit link refers to


    And that link just doesn't work.
    Is it possible at all to use the DataObjectManager in the widget area? Are there any examples out there?

    Here's the relevant code for the widget

    class NivoSliderWidget extends Widget {

       static $db = array(
          'effect' => "Enum('sliceDown,sliceDownLeft,sliceUp,sliceUpLeft,sliceUpDown,sliceUpDownLeft,fold,fade,random','random')",

       static $has_many = array('NivoSliderItems' => 'NivoSliderItem');
       public function getCMSFields() {
          $f = new FieldSet(
             new DropdownField('effect',"Effect", singleton('NivoSliderWidget')->dbObject('effect')->enumValues()),
             new TextField('captionOpacity','Universal caption opacity 0-1'),
             new TabSet("Tabs",
                new Tab("Items",
                   new DataObjectManager($this, 'NivoSliderItems', 'NivoSliderItem', array(
                      'Thumbnail' => _t('Image.PLURALNAME'),
                      'Title' => _t('SiteTree.METATITLE'),
                      'Tagline' => _t('SiteTree.METADESC')),
          return $f;

    And the DataObject for the NivoSliderItem looks like:

    class NivoSliderItem extends DataObject {
       static $db = array (
          'Title' => 'Text',
          'Tagline' => 'Text'

       static $has_one = array(
          'NivoSliderWidget' => 'NivoSliderWidget',
          'PanelImage' => 'Image',
       'PanelLink' => 'SiteTree'
       static $api_access = true;
       public function getCMSFields_forPopup(){
        $imager=new $image('PanelImage',_t('Image.SINGULARNAME')." ...");
          return new FieldSet(
             new TextField('Title',_t('SiteTree.METATITLE')),
             new TextField('Tagline',_t('SiteTree.METADESC')),
             new $tree("PanelLinkID",_t('RedirectorPage.REDIRECTTOPAGE'),"SiteTree")

    Any idea's?
    Btw, the item show is added manually to the database

    Best regards,

  • Aaron Brockhurst
    Community Member
    30 Posts

    Re: Using a DataObjectManager in widget Link to this post

    Did you find a solution to this?

    Is it possible to have either a DataobjectManager or ComplexTableField in a widget?


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