/** * Edit the cms fields in the CMS * * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab('Root.Main', DateField::create('DatePublished', 'Enter a published date')->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('dmyseparator', ' ')->setConfig('showcalendar', true)); $fields->addFieldToTab('Root.Main', $uploadField = new UploadField($name = 'ArticleSummaryImage', $title = 'Upload an article summary image')); $fields->addFieldToTab('Root.Main', new HTMLEditorField('Summary', 'Summary')); $tagfield = TagField::create('NewsTags', 'News Tags', NewsTag::get(), $this->NewsTags())->setShouldLazyLoad(true)->setCanCreate(true); $fields->addFieldToTab('Root.Main', $tagfield); return $fields; }
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; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName("Tags"); $fields->removeByName("Notes"); $tag_field = TagField::create('Tags', null, ContactTag::get(), $this->Tags())->setRightTitle(_t("Contacts.TagDescription", "List of tags related to this contact, seperated by a comma."))->setShouldLazyLoad(true); if ($this->ID) { $gridField = GridField::create('Notes', 'Notes', $this->Notes()); $config = GridFieldConfig_RelationEditor::create(); $gridField->setConfig($config); $fields->addFieldToTab("Root.Notes", $gridField); } $fields->addFieldToTab("Root.Main", $tag_field); return $fields; }
/** * {@inheritdoc} */ public function getCMSFields() { Requirements::css(BLOGGER_DIR . '/css/cms.css'); Requirements::javascript(BLOGGER_DIR . '/js/cms.js'); $self =& $this; $this->beforeUpdateCMSFields(function ($fields) use($self) { $uploadField = UploadField::create('FeaturedImage', _t('BlogPost.FeaturedImage', 'Featured Image')); $uploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); /** * @var FieldList $fields */ $fields->insertAfter($uploadField, 'Content'); $summary = HtmlEditorField::create('Summary', false); $summary->setRows(5); $summary->setDescription(_t('BlogPost.SUMMARY_DESCRIPTION', 'If no summary is specified the first 30 words will be used.')); $summaryHolder = ToggleCompositeField::create('CustomSummary', _t('BlogPost.CUSTOMSUMMARY', 'Add A Custom Summary'), array($summary)); $summaryHolder->setHeadingLevel(4); $summaryHolder->addExtraClass('custom-summary'); $fields->insertAfter($summaryHolder, 'FeaturedImage'); $fields->push(HiddenField::create('MenuTitle')); $urlSegment = $fields->dataFieldByName('URLSegment'); $urlSegment->setURLPrefix($self->Parent()->RelativeLink()); $fields->removeFieldsFromTab('Root.Main', array('MenuTitle', 'URLSegment')); $authorField = ListboxField::create('Authors', _t('BlogPost.Authors', 'Authors'), $self->getCandidateAuthors()->map()->toArray())->setMultiple(true); $authorNames = TextField::create('AuthorNames', _t('BlogPost.AdditionalCredits', 'Additional Credits'), null, 1024)->setDescription(_t('BlogPost.AdditionalCredits_Description', 'If some authors of this post don\'t have CMS access, enter their name(s) here. You can separate multiple names with a comma.')); if (!$self->canEditAuthors()) { $authorField = $authorField->performDisabledTransformation(); $authorNames = $authorNames->performDisabledTransformation(); } $publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date')); $publishDate->getDateField()->setConfig('showcalendar', true); if (!$self->PublishDate) { $publishDate->setDescription(_t('BlogPost.PublishDate_Description', 'Will be set to "now" if published without a value.')); } // Get categories and tags $parent = $self->Parent(); $categories = $parent instanceof Blog ? $parent->Categories() : BlogCategory::get(); $tags = $parent instanceof Blog ? $parent->Tags() : BlogTag::get(); $options = BlogAdminSidebar::create($publishDate, $urlSegment, TagField::create('Categories', _t('BlogPost.Categories', 'Categories'), $categories, $self->Categories())->setCanCreate($self->canCreateCategories())->setShouldLazyLoad(true), TagField::create('Tags', _t('BlogPost.Tags', 'Tags'), $tags, $self->Tags())->setCanCreate($self->canCreateTags())->setShouldLazyLoad(true), $authorField, $authorNames)->setTitle('Post Options'); $options->setName('blog-admin-sidebar'); $fields->insertBefore($options, 'Root'); }); $fields = parent::getCMSFields(); $fields->fieldByName('Root')->setTemplate('TabSet_holder'); return $fields; }