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->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(
|
||||
$publishDate,
|
||||
$urlSegment,
|
||||
TagField::create(
|
||||
'Categories',
|
||||
_t('BlogPost.Categories', 'Categories'),
|
||||
$self->Parent()->Categories(),
|
||||
$categories,
|
||||
$self->Categories()
|
||||
)
|
||||
->setCanCreate($self->canCreateCategories())
|
||||
@ -236,7 +245,7 @@ class BlogPost extends Page {
|
||||
TagField::create(
|
||||
'Tags',
|
||||
_t('BlogPost.Tags', 'Tags'),
|
||||
$self->Parent()->Tags(),
|
||||
$tags,
|
||||
$self->Tags()
|
||||
)
|
||||
->setCanCreate($self->canCreateTags())
|
||||
|
Loading…
Reference in New Issue
Block a user