mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
BUG Fix BlogPost crashing when created under a non-blog parent
This commit is contained in:
parent
1430018b67
commit
0941b4ed96
@ -222,13 +222,22 @@ class BlogPost extends Page {
|
|||||||
$publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date'));
|
$publishDate = DatetimeField::create('PublishDate', _t('BlogPost.PublishDate', 'Publish Date'));
|
||||||
$publishDate->getDateField()->setConfig('showcalendar', true);
|
$publishDate->getDateField()->setConfig('showcalendar', true);
|
||||||
|
|
||||||
|
// 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(
|
$options = BlogAdminSidebar::create(
|
||||||
$publishDate,
|
$publishDate,
|
||||||
$urlSegment,
|
$urlSegment,
|
||||||
TagField::create(
|
TagField::create(
|
||||||
'Categories',
|
'Categories',
|
||||||
_t('BlogPost.Categories', 'Categories'),
|
_t('BlogPost.Categories', 'Categories'),
|
||||||
$self->Parent()->Categories(),
|
$categories,
|
||||||
$self->Categories()
|
$self->Categories()
|
||||||
)
|
)
|
||||||
->setCanCreate($self->canCreateCategories())
|
->setCanCreate($self->canCreateCategories())
|
||||||
@ -236,7 +245,7 @@ class BlogPost extends Page {
|
|||||||
TagField::create(
|
TagField::create(
|
||||||
'Tags',
|
'Tags',
|
||||||
_t('BlogPost.Tags', 'Tags'),
|
_t('BlogPost.Tags', 'Tags'),
|
||||||
$self->Parent()->Tags(),
|
$tags,
|
||||||
$self->Tags()
|
$self->Tags()
|
||||||
)
|
)
|
||||||
->setCanCreate($self->canCreateTags())
|
->setCanCreate($self->canCreateTags())
|
||||||
|
Loading…
Reference in New Issue
Block a user