mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Fixed credits
This commit is contained in:
parent
56f9d0c906
commit
4ee278abb3
@ -330,7 +330,62 @@ class BlogPost extends Page {
|
||||
return Controller::join_links($this->Parent()->Link("archive"), $date->format("Y"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves static and dynamic authors linked to this post.
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function getCredits()
|
||||
{
|
||||
$list = new ArrayList();
|
||||
|
||||
$list->merge($this->getDynamicCredits());
|
||||
$list->merge($this->getStaticCredits());
|
||||
|
||||
return $list->sort('Name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves dynamic authors linked to this post.
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
protected function getDynamicCredits()
|
||||
{
|
||||
$items = new ArrayList();
|
||||
|
||||
foreach($this->Authors() as $author) {
|
||||
$items->push(
|
||||
$author->customise(array(
|
||||
'URL' => $this->Parent->ProfileLink($author->URLSegment),
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves static authors linked to this post.
|
||||
*
|
||||
* @return ArrayList
|
||||
*/
|
||||
protected function getStaticCredits()
|
||||
{
|
||||
$items = new ArrayList();
|
||||
|
||||
$authors = array_filter(preg_split('/\s*,\s*/', $this->AuthorNames));
|
||||
|
||||
foreach ($authors as $author) {
|
||||
$item = new ArrayData(array(
|
||||
'Name' => $author,
|
||||
));
|
||||
|
||||
$items->push($item);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label for BlogPost.Title to 'Post Title' (Rather than 'Page name')
|
||||
|
@ -23,18 +23,9 @@
|
||||
<%t Blog.Posted "Posted" %>
|
||||
<a href="$MonthlyArchiveLink">$PublishDate.ago</a>
|
||||
|
||||
<% if $Authors || $AuthorNames %>
|
||||
<% if $Credits %>
|
||||
<%t Blog.By "by" %>
|
||||
<% if $Authors %><% loop $Authors %>
|
||||
<% if $URLSegment %>
|
||||
<a href="{$Up.Parent.ProfileLink($URLSegment)}">$Name.XML</a>
|
||||
<% else %>
|
||||
$Name.XML
|
||||
<% end_if %>
|
||||
<% if not $Last || $Up.AuthorNames %>,<% end_if %>
|
||||
<% end_loop %><% end_if %>
|
||||
<% if $AuthorNames %>
|
||||
$AuthorNames
|
||||
<% end_if %>
|
||||
<% loop $Credits %><% if not $First && not $Last %>, <% end_if %><% if not $First && $Last %> and <% end_if %><% if $URLSegment %><a href="$URL">$Name.XML</a><% else %>$Name.XML<% end_if %><% end_loop %>
|
||||
<% end_if %>
|
||||
|
||||
</p>
|
||||
|
Loading…
Reference in New Issue
Block a user