Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Preview: DataObjectManager module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Go to End
Author Topic: 60124 Views
  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    bgribaudo, in my code and all the examples i have seen it is required to have a reference to your page type from the resource object. Are you sure you shouldn't have something like

    class QualityPDF extends PDFResource
    {
    static $has_one = array (
    'Page' => 'QualityPDFPage '
    );
    }


    and then you could setParentClass('QualityPDFPage')

    Good Luck, I'm no expert.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Yeah, the parent class has to be the one that's in your has_one relationship. Put it this way.. setParentClass() tells the table which ID field it will update. so setParentClass('Page') means it will try to update PageID on the object. setParentClass('QualityPDFPage') will try to update the field QualityPDFPageID.

    @David -- Thanks for these fixes. I've checked them in.

  • Taffy
    Avatar
    Community Member
    119 Posts

    Re: Preview: DataObjectManager module Link to this post

    Not sure if this has been posted but here is the link to the module on the unsuported modules page http://silverstripe.org/dataobjectmanager-module/

  • hu
    Avatar
    Community Member
    21 Posts

    Re: Preview: DataObjectManager module Link to this post

    There is a "small bug" behind the links on page navigation for lists. The parameters of First, Next, Previous an Last are twice in parameter string.

    admin/EditForm/field/Products?ctf[Products][per_page]=10&ctf[Products][showall]=0&ctf[Products][sort]=SortOrder&ctf[Products][sort_dir]=DESC&ctf[Products][search]=&ctf[Products][filter]=&ctf[Products][start]=10&ctf[Products][per_page]=10&ctf[Products][showall]=0&ctf[Products][sort]=SortOrder&ctf[Products][sort_dir]=DESC&ctf[Products][search]=&ctf[Products][filter]=

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hey! Look at that! It got posted. Finally. Still waiting for the ImageGallery to get some love.

    @hu - Thanks for the heads up. I'll look at that.

  • Ben Gribaudo
    Avatar
    Community Member
    181 Posts

    Re: Preview: DataObjectManager module Link to this post

    Uncle Cheese,

    I think I'm missing something. I'm setting setParentClass('Page') on the FileDataObjectManager instance, yet PDFResource's PageID column stays set at 0. Any clues?

    Ben

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    Can you show me QualityChildPage?

  • Ben Gribaudo
    Avatar
    Community Member
    181 Posts

    Re: Preview: DataObjectManager module Link to this post

    Sure thing.

    class QualityChildPage extends Page {
       static $db = array('Category' => "Enum('Links, Workplace, Family, Stories, Extras','Links')");
       static $default_parent = 'QualityHomePage';
       static $can_be_root = false;
       static $allowed_children = array();
       static $icon = "themes/memberscf/images/pageicons/cqarticle";

       function getCMSFields() {
          $fields = parent::getCMSFields();

          $fields->addFieldToTab('Root.Content.Metadata', new DropdownField('Category', 'Category', singleton('QualityChildPage')->dbObject('Category')->enumValues()));
          return $fields;
       }
       
       function Quality() {
          return $this->Parent()->Quality;
       }
    }

    class QualityChildPage_Controller extends Page_Controller {
       protected $sidebar = 'QualitySideBar';

    public function CategoryLinks($category) {
    return QualityHelper::CategoryLinks($category, $this->Parent());
    }
    }

    class QualityHelper {
       public static function CategoryLinks($category, $quality) {
    $results = new DataObjectSet();
    foreach($quality->Children() as $child) {
    if ($child->Category != $category) continue;
    $results->push($child);
    }

    return $results;
    }
    }

    60124 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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.