mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
ENHANCEMENT Added SubscribeRSSWidget for linking directly to blog RSS from the BlogHolder
This commit is contained in:
parent
684287e11d
commit
4b6a22f6a3
56
code/SubscribeRSSWidget.php
Normal file
56
code/SubscribeRSSWidget.php
Normal 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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
4
css/subscribersswidget.css
Normal file
4
css/subscribersswidget.css
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.subscribeLink {
|
||||||
|
background: url(../images/feed-icon-14x14.png) no-repeat left center;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
5
templates/SubscribeRSSWidget.ss
Normal file
5
templates/SubscribeRSSWidget.ss
Normal 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>
|
Loading…
Reference in New Issue
Block a user