From 289940b7e725ef664bcabc790b03d58d76d8f5d9 Mon Sep 17 00:00:00 2001 From: Saophalkun Ponlu Date: Thu, 18 Oct 2012 10:10:16 +1300 Subject: [PATCH] Add an option show full blog entry on the holder https://github.com/silverstripe/silverstripe-blog/issues/57 --- code/BlogEntry.php | 14 ++++++++++++++ code/BlogHolder.php | 2 ++ templates/Includes/BlogSummary.ss | 8 ++++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/code/BlogEntry.php b/code/BlogEntry.php index 32202e0..f892c65 100644 --- a/code/BlogEntry.php +++ b/code/BlogEntry.php @@ -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 { diff --git a/code/BlogHolder.php b/code/BlogHolder.php index ff683e8..000b356 100644 --- a/code/BlogHolder.php +++ b/code/BlogHolder.php @@ -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); diff --git a/templates/Includes/BlogSummary.ss b/templates/Includes/BlogSummary.ss index 897fd06..203bac2 100644 --- a/templates/Includes/BlogSummary.ss +++ b/templates/Includes/BlogSummary.ss @@ -9,8 +9,12 @@ <% end_loop %>

<% end_if %> - -

$Content.FirstParagraph(html)

+ + <% if BlogHolder.ShowFullEntry %> + $Content + <% else %> +

$Content.FirstParagraph(html)

+ <% end_if %>

$Comments.Count comments | Read the full post