Add an option show full blog entry on the holder

https://github.com/silverstripe/silverstripe-blog/issues/57
This commit is contained in:
Saophalkun Ponlu 2012-10-18 10:10:16 +13:00
parent 59731c2b13
commit 289940b7e7
3 changed files with 22 additions and 2 deletions

View File

@ -230,6 +230,20 @@ class BlogEntry extends Page {
'Date ASC'
);
}
/**
* Get the blog holder of this entry
*
* @return BlogHolder
*/
function getBlogHolder() {
$holder = null;
if($this->ParentID && $this->Parent()->ClassName == 'BlogHolder') {
$holder = $this->Parent();
}
return $holder;
}
}
class BlogEntry_Controller extends Page_Controller {

View File

@ -23,6 +23,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
static $db = array(
'TrackBacksEnabled' => 'Boolean',
'AllowCustomAuthors' => 'Boolean',
'ShowFullEntry' => 'Boolean',
);
static $has_one = array(
@ -43,6 +44,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
$fields->addFieldToTab('Root.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks'), "Content");
$fields->addFieldToTab('Root.Main', new DropdownField('OwnerID', 'Blog owner', array_merge(array('' => "(None)"), $blogOwners->map('ID', 'Name')->toArray())), "Content");
$fields->addFieldToTab('Root.Main', new CheckboxField('AllowCustomAuthors', 'Allow non-admins to have a custom author field'), "Content");
$fields->addFieldToTab("Root.Main", new CheckboxField("ShowFullEntry", "Show Full Entry"), "Content");
$this->extend('updateCMSFields', $fields);

View File

@ -9,8 +9,12 @@
<% end_loop %>
</p>
<% end_if %>
<p>$Content.FirstParagraph(html)</p>
<% if BlogHolder.ShowFullEntry %>
$Content
<% else %>
<p>$Content.FirstParagraph(html)</p>
<% end_if %>
<p class="blogVitals"><a href="$Link#PageComments_holder" class="comments" title="View Comments for this post">$Comments.Count comments</a> | <a href="$Link" class="readmore" title="Read Full Post">Read the full post</a></p>
</div>