mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #317 from tractorcow/pulls/fix-nonblog-parent
BUG Fix crash if parent page isn't Blog type
This commit is contained in:
commit
a87e0f77e6
@ -602,14 +602,26 @@ class BlogPost extends Page {
|
||||
* @return ArrayList
|
||||
*/
|
||||
protected function getDynamicCredits() {
|
||||
$items = new ArrayList();
|
||||
// Find best page to host user profiles
|
||||
$parent = $this->Parent();
|
||||
if(! ($parent instanceof Blog) ) {
|
||||
$parent = Blog::get()->first();
|
||||
}
|
||||
|
||||
// If there is no parent blog, return list undecorated
|
||||
if(!$parent) {
|
||||
$items = $this->Authors()->toArray();
|
||||
return new ArrayList($items);
|
||||
}
|
||||
|
||||
// Update all authors
|
||||
$items = new ArrayList();
|
||||
foreach($this->Authors() as $author) {
|
||||
$items->push(
|
||||
$author->customise(array(
|
||||
'URL' => $this->Parent->ProfileLink($author->URLSegment),
|
||||
))
|
||||
);
|
||||
// Add link for each author
|
||||
$author = $author->customise(array(
|
||||
'URL' => $parent->ProfileLink($author->URLSegment),
|
||||
));
|
||||
$items->push($author);
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
Loading…
Reference in New Issue
Block a user