Skip to content

Commit

Permalink
Add an option show full blog entry on the holder
Browse files Browse the repository at this point in the history
  • Loading branch information
phalkunz committed Oct 17, 2012
1 parent 59731c2 commit 289940b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
14 changes: 14 additions & 0 deletions code/BlogEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,20 @@ function NextBlogEntry() {
'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 {
Expand Down
2 changes: 2 additions & 0 deletions code/BlogHolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
static $db = array(
'TrackBacksEnabled' => 'Boolean',
'AllowCustomAuthors' => 'Boolean',
'ShowFullEntry' => 'Boolean',
);

static $has_one = array(
Expand All @@ -43,6 +44,7 @@ function getCMSFields() {
$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);

Expand Down
8 changes: 6 additions & 2 deletions templates/Includes/BlogSummary.ss
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 289940b

Please sign in to comment.