mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Added tag field
This commit is contained in:
parent
d58b376bf1
commit
a08fa42bc7
@ -132,16 +132,18 @@ class BlogPost extends Page {
|
|||||||
$options = BlogAdminSidebar::create(
|
$options = BlogAdminSidebar::create(
|
||||||
$publishDate = DatetimeField::create("PublishDate", _t("BlogPost.PublishDate", "Publish Date")),
|
$publishDate = DatetimeField::create("PublishDate", _t("BlogPost.PublishDate", "Publish Date")),
|
||||||
$urlSegment,
|
$urlSegment,
|
||||||
ListboxField::create(
|
TagField::create(
|
||||||
"Categories",
|
'Categories',
|
||||||
_t("BlogPost.Categories", "Categories"),
|
_t('BlogPost.Categories', 'Categories'),
|
||||||
$self->Parent()->Categories()->map()->toArray()
|
BlogCategory::get()->map(),
|
||||||
)->setMultiple(true),
|
$self->Parent()->Categories()->map()
|
||||||
ListboxField::create(
|
),
|
||||||
"Tags",
|
TagField::create(
|
||||||
_t("BlogPost.Tags", "Tags"),
|
'Tags',
|
||||||
$self->Parent()->Tags()->map()->toArray()
|
_t('BlogPost.Tags', 'Tags'),
|
||||||
)->setMultiple(true),
|
BlogTag::get()->map(),
|
||||||
|
$self->Parent()->Tags()->map()
|
||||||
|
),
|
||||||
$authorField,
|
$authorField,
|
||||||
$authorNames
|
$authorNames
|
||||||
)->setTitle('Post Options');
|
)->setTitle('Post Options');
|
||||||
@ -184,7 +186,25 @@ class BlogPost extends Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets blog relationship on all categories and tags assigned to this post.
|
||||||
|
*
|
||||||
|
* @throws ValidationException
|
||||||
|
*/
|
||||||
|
public function onAfterWrite()
|
||||||
|
{
|
||||||
|
parent::onAfterWrite();
|
||||||
|
|
||||||
|
foreach ($this->Categories() as $category) {
|
||||||
|
$category->BlogID = $this->ParentID;
|
||||||
|
$category->write();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->Tags() as $tag) {
|
||||||
|
$tag->BlogID = $this->ParentID;
|
||||||
|
$tag->write();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the publish date to see if the blog post has actually been published.
|
* Checks the publish date to see if the blog post has actually been published.
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "silverstripe/blog",
|
"name": "silverstripe/blog",
|
||||||
"description": "A fresh take on blogging in Silverstripe set out to tackle the issue of a cluttered Site Tree.",
|
"description": "A fresh take on blogging in Silverstripe set out to tackle the issue of a cluttered Site Tree.",
|
||||||
"keywords": ["silverstripe", "blog", "news"],
|
"keywords": [
|
||||||
|
"silverstripe",
|
||||||
|
"blog",
|
||||||
|
"news"
|
||||||
|
],
|
||||||
"type": "silverstripe-module",
|
"type": "silverstripe-module",
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/cms": ">=3.1.0",
|
"silverstripe/cms": ">=3.1.0",
|
||||||
"silverstripe/lumberjack": "~1.1"
|
"silverstripe/lumberjack": "~1.1",
|
||||||
|
"silverstripe/tag-field": "~1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/PHPUnit": "~3.7@stable"
|
"phpunit/PHPUnit": "~3.7@stable"
|
||||||
|
Loading…
Reference in New Issue
Block a user