public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.Main", new TextField("Description", "Description", "", 100));
     $conf = GridFieldConfig_RelationEditor::create(10);
     $conf->addComponent($sortable = new GridFieldSortableRows('SortID'));
     //Append new GalleryItems to the top
     $sortable->setAppendToTop(true);
     $field = TagField::create('GalleryTags', 'Gallery Tags', GalleryTag::get(), $this->GalleryTags())->setShouldLazyLoad(true)->setCanCreate(true);
     // new tag DataObjects can be created;
     $fields->addFieldToTab('Root.Tags', $field);
     $fields->addFieldToTab('Root.MyAlbum', new GridField('GalleryItems', 'My Album', $this->GalleryItems(), $conf));
     return $fields;
 }
Пример #2
0
 public function ActiveGalleryTags()
 {
     /**
      *  @TODO: think about caching this
      * @TODO: Also currently these are not order
      *
      * */
     $ids = array_values($this->Children()->column('ID'));
     return GalleryTag::get()->distinct(true)->filterByCallback(function ($tag) use($ids) {
         foreach ($tag->GalleryAlbums()->getIDList() as $id) {
             if (in_array($id, $ids)) {
                 return true;
             }
         }
         return false;
     });
 }