Für den seltenen Fall, daß man JEDEN Artikel AUTOMATISCH auch als Feed anbieten will, etwa der Art, daß man eine Artikel URL nur mit dem Zusatz
?view=article&format=feed&type=rss
aufrufen muß, gibt es leider keine einfache Lösung.
Die komplizierte lautet: man muß die com_content-Komponente um eine Feed-View erweitern. Die könnte so aussehen:
view.feed.php
<?php
/**
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML Article View class for the Content component
*
* @package Joomla.Site
* @subpackage com_content
* @since 1.5
*/
class ContentViewArticle extends JViewLegacy
{
protected $item;
protected $params;
protected $print;
protected $state;
protected $user;
function display($tpl = null)
{
// Initialise variables.
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$params = $app->getParams();
$feedEmail = $app->getCfg('feed_email', 'author');
$siteEmail = $app->getCfg('mailfrom');
$this->item = $this->get('Item');
$doc->link = JRoute::_('index.php?option=com_content&view=article&format=feed');
// Get some data from the model
JRequest::setVar('limit', $app->getCfg('feed_limit'));
$categories = JCategories::getInstance('Content');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
// Create a shortcut for $item.
$item = &$this->item;
// Add router helpers.
$item->slug = $item->alias ? ($item->id.':'.$item->alias) : $item->id;
$item->catslug = $item->category_alias ? ($item->catid.':'.$item->category_alias) : $item->catid;
$item->parent_slug = $item->category_alias ? ($item->parent_id.':'.$item->parent_alias) : $item->parent_id;
// Get row fulltext
$description = $item->introtext;
$description .= $item->fulltext;
$author = $item->author;
// Load individual item creator class
$feed_item = new JFeedItem();
$feed_item->title = $item->title;
$feed_item->link = JRoute::_(ContentHelperRoute::getArticleRoute( $item->id, $item->catid ));
$feed_item->date = JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC2'));
$feed_item->category = array();
$feed_item->category[] = $this->item->category_alias;
$feed_item->author = $item->author;
if ($feedEmail == 'site')
{
$feed_item->authorEmail = $siteEmail;
}
elseif ($feedEmail === 'author')
{
$feed_item->authorEmail = $this->item->author_email;
}
// Load item description and add div
$feed_item->description = '<div class="feed-description">'.$description.'</div>';
// Loads item info into rss array
$doc->addItem($feed_item);
}
}
Damit automatisch auch ein Link im Header zum Feed eingebaut wird (den Feedreader dann automatisch finden können), muß noch diese Zeile in der prepareDocument-Funktion der Artikelstandardview article.view.php eingebaut werden:
protected function _prepareDocument()
{
....
$this->document->addCustomTag('<link href="'.JRoute::_(ContentHelperRoute::getArticleRoute( $this->item->id, $this->item->catid )).'?view=article&format=feed&type=rss" rel="alternate" type="application/rss+xml" title="RSS 2.0" />');
...