diff --git a/code/BlogEntry.php b/code/BlogEntry.php index 878b792..abe4468 100644 --- a/code/BlogEntry.php +++ b/code/BlogEntry.php @@ -151,6 +151,21 @@ class BlogEntry extends Page { function EditURL() { return $this->getParent()->Link('post') . '/' . $this->ID . '/'; } + + /** + * Check to see if trackbacks are enabled. + */ + function TrackBacksEnabled() { + return $this->getParent()->TrackBacksEnabled; + } + + function trackbackping() { + if($this->TrackBacksEnabled()) { + return $this->extInstance('TrackBackDecorator')->trackbackping(); + } else { + Director::redirect($this->Link()); + } + } /** * Call this to enable WYSIWYG editing on your blog entries. diff --git a/code/BlogHolder.php b/code/BlogHolder.php index afb3a2f..a3fe938 100644 --- a/code/BlogHolder.php +++ b/code/BlogHolder.php @@ -13,8 +13,9 @@ class BlogHolder extends Page { static $icon = "blog/images/blogholder"; static $db = array( - "LandingPageFreshness" => "Varchar", - "Name" => "Varchar" + 'LandingPageFreshness' => 'Varchar', + 'Name' => 'Varchar', + 'TrackBacksEnabled' => 'Boolean' ); static $has_one = array( @@ -31,10 +32,6 @@ class BlogHolder extends Page { 'BlogEntry' ); - static $defaults = array( - "LandingPageFreshness" => "3 MONTH", - ); - function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeFieldFromTab("Root.Content.Main","Content"); @@ -54,8 +51,10 @@ class BlogHolder extends Page { "9 MONTH" => "Last 9 months' entries", "10 MONTH" => "Last 10 months' entries", "11 MONTH" => "Last 11 months' entries", - "12 MONTH" => "Last year's entries", + "12 MONTH" => "Last year's entries" ))); + + $fields->addFieldToTab('Root.Content.Main', new CheckboxField('TrackBacksEnabled', 'Enable TrackBacks')); return $fields; } diff --git a/templates/Layout/BlogEntry.ss b/templates/Layout/BlogEntry.ss index d5c2bfb..cc37068 100644 --- a/templates/Layout/BlogEntry.ss +++ b/templates/Layout/BlogEntry.ss @@ -23,6 +23,8 @@ <% if CurrentMember %>

<% _t('EDITTHIS', 'Edit this post') %> | <% _t('UNPUBLISHTHIS', 'Unpublish this post') %>

<% end_if %> - <% include TrackBacks %> + <% if TrackBacksEnabled %> + <% include TrackBacks %> + <% end_if %> $PageComments