mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #21 from purplespider/beforeupdatecmsfields
Blog: Wrapped CMS fields in beforeUpdateCMSFields
This commit is contained in:
commit
fb85da54de
@ -33,45 +33,48 @@ class Blog extends Page {
|
|||||||
|
|
||||||
|
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
$fields = parent::getCMSFields();
|
$this->beforeUpdateCMSFields(function($fields) {
|
||||||
|
|
||||||
$posts = $this->getBlogPosts();
|
$posts = $this->getBlogPosts();
|
||||||
$excluded = $this->getExcludedSiteTreeClassNames();
|
$excluded = $this->getExcludedSiteTreeClassNames();
|
||||||
if(!empty($excluded)) {
|
if(!empty($excluded)) {
|
||||||
$posts = $posts->filter("ClassName", $excluded);
|
$posts = $posts->filter("ClassName", $excluded);
|
||||||
$gridField = new GridField(
|
$gridField = new GridField(
|
||||||
"BlogPost",
|
"BlogPost",
|
||||||
_t("Blog.BlogPosts", "Blog Posts"),
|
_t("Blog.BlogPosts", "Blog Posts"),
|
||||||
$posts,
|
$posts,
|
||||||
GridFieldConfig_BlogPost::create()
|
GridFieldConfig_BlogPost::create()
|
||||||
|
);
|
||||||
|
$fields->addFieldToTab("Root.BlogPosts", $gridField);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create categories and tag config
|
||||||
|
$config = GridFieldConfig_RecordEditor::create();
|
||||||
|
$config->removeComponentsByType("GridFieldAddNewButton");
|
||||||
|
$config->addComponent(new GridFieldAddByDBField("buttons-before-left"));
|
||||||
|
|
||||||
|
$categories = GridField::create(
|
||||||
|
"Categories",
|
||||||
|
_t("Blog.Categories", "Categories"),
|
||||||
|
$this->Categories(),
|
||||||
|
$config
|
||||||
);
|
);
|
||||||
$fields->addFieldToTab("Root.BlogPosts", $gridField);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create categories and tag config
|
$tags = GridField::create(
|
||||||
$config = GridFieldConfig_RecordEditor::create();
|
"Tags",
|
||||||
$config->removeComponentsByType("GridFieldAddNewButton");
|
_t("Blog.Tags", "Tags"),
|
||||||
$config->addComponent(new GridFieldAddByDBField("buttons-before-left"));
|
$this->Tags(),
|
||||||
|
$config
|
||||||
|
);
|
||||||
|
|
||||||
$categories = GridField::create(
|
$fields->addFieldsToTab("Root.BlogOptions", array(
|
||||||
"Categories",
|
$categories,
|
||||||
_t("Blog.Categories", "Categories"),
|
$tags
|
||||||
$this->Categories(),
|
));
|
||||||
$config
|
|
||||||
);
|
|
||||||
|
|
||||||
$tags = GridField::create(
|
|
||||||
"Tags",
|
|
||||||
_t("Blog.Tags", "Tags"),
|
|
||||||
$this->Tags(),
|
|
||||||
$config
|
|
||||||
);
|
|
||||||
|
|
||||||
$fields->addFieldsToTab("Root.BlogOptions", array(
|
|
||||||
$categories,
|
|
||||||
$tags
|
|
||||||
));
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$fields = parent::getCMSFields();
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user