ENHANCEMENT Added SubscribeRSSWidget for linking directly to blog RSS from the BlogHolder

This commit is contained in:
Sean Harvey 2008-12-10 06:49:06 +00:00
parent 684287e11d
commit 4b6a22f6a3
3 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,56 @@
<?php
/**
* A simple widget that just shows a link
* to this website's blog RSS, with an RSS
* icon.
*
* @package blog
*/
class SubscribeRSSWidget extends Widget {
static $db = array(
'Title' => 'Varchar'
);
static $title = 'Subscribe via RSS';
static $cmsTitle = 'Subscribe via RSS widget';
static $description = 'Shows a link allowing a user to subscribe to this blog via RSS.';
/**
* Get the BlogHolder instance that this widget
* is located on.
*
* @return BlogHolder
*/
function getBlogHolder() {
$page = Director::currentPage();
if($page instanceof BlogHolder) {
return $page;
} elseif(($page instanceof BlogEntry) && ($page->getParent() instanceof BlogHolder)) {
return $page->getParent();
} else {
return DataObject::get_one('BlogHolder');
}
}
/**
* Return an absolute URL based on the BlogHolder
* that this widget is located on.
*
* @return string
*/
function RSSLink() {
Requirements::themedCSS('subscribersswidget');
$blogHolder = $this->getBlogHolder();
if($blogHolder) {
return $blogHolder->Link() . 'rss';
}
}
}
?>

View File

@ -0,0 +1,4 @@
.subscribeLink {
background: url(../images/feed-icon-14x14.png) no-repeat left center;
padding-left: 20px;
}

View File

@ -0,0 +1,5 @@
<p>
<a href="$RSSLink" class="subscribeLink" title="<% _t('SUBSCRIBETITLE', 'Subscribe to this blog via RSS') %>">
<% _t('SUBSCRIBETEXT', 'Subscribe') %>
</a>
</p>