Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » What to do if I want to use the DataObjectManager with different types of pages?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 764 Views
  • fiord
    Avatar
    Community Member
    79 Posts

    What to do if I want to use the DataObjectManager with different types of pages? Link to this post

    Now I add photos to the FotoPage with DataObjectManager (Class Foto):

    class Foto extends DataObject
    {
       static $db = array (
          'Name' => 'Text',
          'Description' => 'Text',
       );
       
       static $has_one = array (
          'Attachment' => 'File',
          'FotoPage' => 'FotoPage'
       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new TextField('Name'),
             new TextareaField('Description'),
             //new DropdownField('Category','Category', singleton('Resource')->dbObject('Category')->enumValues()),
             new FileIFrameField('Attachment')
          );
       }
    }

    what should I do to use the module on different types of pages: FotoPage and NewsPage?
    may be sufficient to fix the code only:
    'FotoPage' => 'FotoPage'   
    on
    'FotoPage' => 'Page'
    ?

  • UncleCheese
    Avatar
    4085 Posts

    Re: What to do if I want to use the DataObjectManager with different types of pages? Link to this post

    You can add as many relations as you want.

    static $has_one = array (
    'Attachment' => 'File',
    'FotoPage' => 'FotoPage',
    'SomeOtherPage' => 'SomePage',
    'AnotherPage' => 'AnotherPage'
    );

    764 Views
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.