FEATURE: Enable disabling of TrackBacks

This commit is contained in:
Andrew O'Neil 2008-12-16 22:35:32 +00:00
parent 3443ff9f60
commit 8e708d98a7
3 changed files with 24 additions and 8 deletions

View File

@ -152,6 +152,21 @@ class BlogEntry extends Page {
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.
* By default the blog uses BBCode

View File

@ -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,9 +51,11 @@ 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;
}

View File

@ -23,6 +23,8 @@
<% if CurrentMember %><p><a href="$EditURL" id="editpost" title="<% _t('EDITTHIS', 'Edit this post') %>"><% _t('EDITTHIS', 'Edit this post') %></a> | <a href="$Link(unpublishPost)" id="unpublishpost"><% _t('UNPUBLISHTHIS', 'Unpublish this post') %></a></p><% end_if %>
<% include TrackBacks %>
<% if TrackBacksEnabled %>
<% include TrackBacks %>
<% end_if %>
$PageComments
</div>