Пример генерации RSS feed в Joomla
Joomla RSS
14.12.2016
Создаем файл представления: /components/com_NAME/views/items/view.feed.php
Полная ссылка будет: /index.php?option=com_NAME&view=items&format=feed&type=rss
Общий вид кода представления:
view.feed.php (Download)
<?php defined('_JEXEC') or die; /** * HTML View class for the Tags component * * @since 3.1 */ class SoBlogViewItems extends JViewLegacy { /** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @return mixed A string if successful, otherwise an Error object. */ public function display($tpl = null) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $document->link = JRoute::_('index.php?option=com_soblog'); $app->input->set('limit', $app->get('feed_limit')); $siteEmail = $app->get('mailfrom'); $fromName = $app->get('fromname'); $feedEmail = $app->get('feed_email', 'none'); $document->editor = $fromName; if ($feedEmail != "none") { $document->editorEmail = $siteEmail; } // Get some data from the model $oItems = $this->get('Items'); if ($oItems !== false) { foreach($oItems as $oItem) { // Strip HTML from feed item title $title = $this->escape($oItem->title); $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); // URL link to tagged item // Change to new routing once it is merged $link = JRoute::_('index.php?option=com_soblog&view=item&id='.$oItem->id); // Strip HTML from feed item description text $description = $oItem->short_text; $date = $oItem->date; // Load individual item creator class $feeditem = new JFeedItem; $feeditem->title = $title; $feeditem->link = $link; $feeditem->description = $description; $feeditem->date = $date; $feeditem->category = SoBlogCommonHelper::getCategoryName($oItem->id_category); // Loads item info into RSS array $document->addItem($feeditem); } } } }