class Rss
Same name in this branch
- 9 core/modules/node/src/Plugin/views/row/Rss.php \Drupal\node\Plugin\views\row\Rss
- 9 core/modules/aggregator/src/Plugin/views/row/Rss.php \Drupal\aggregator\Plugin\views\row\Rss
- 9 core/modules/comment/src/Plugin/views/row/Rss.php \Drupal\comment\Plugin\views\row\Rss
Same name and namespace in other branches
- 11.x core/modules/node/src/Plugin/views/row/Rss.php \Drupal\node\Plugin\views\row\Rss
- 11.x core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\Rss
- 11.x core/modules/comment/src/Plugin/views/row/Rss.php \Drupal\comment\Plugin\views\row\Rss
- 10 core/modules/node/src/Plugin/views/row/Rss.php \Drupal\node\Plugin\views\row\Rss
- 10 core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\Rss
- 10 core/modules/comment/src/Plugin/views/row/Rss.php \Drupal\comment\Plugin\views\row\Rss
- 8.9.x core/modules/node/src/Plugin/views/row/Rss.php \Drupal\node\Plugin\views\row\Rss
- 8.9.x core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\Rss
- 8.9.x core/modules/aggregator/src/Plugin/views/row/Rss.php \Drupal\aggregator\Plugin\views\row\Rss
- 8.9.x core/modules/comment/src/Plugin/views/row/Rss.php \Drupal\comment\Plugin\views\row\Rss
Default style plugin to render an RSS feed.
Plugin annotation
@ViewsStyle(
id = "rss",
title = @Translation("RSS Feed"),
help = @Translation("Generates an RSS feed from a view."),
theme = "views_view_rss",
display_types = {"feed"}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\views\Plugin\views\style\StylePluginBase extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\style\Rss extends \Drupal\views\Plugin\views\style\StylePluginBase
- class \Drupal\views\Plugin\views\style\StylePluginBase extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of Rss
Related topics
41 string references to 'Rss'
- AggregatorRenderingTest::testFeedPage in core/
modules/ aggregator/ tests/ src/ Functional/ AggregatorRenderingTest.php - Creates a feed and checks that feed's page.
- book_node_links_alter in core/
modules/ book/ book.module - Implements hook_node_links_alter().
- CommentLinkBuilder::buildCommentedEntityLinks in core/
modules/ comment/ src/ CommentLinkBuilder.php - CommentLinkBuilderTest::getLinkCombinations in core/
modules/ comment/ tests/ src/ Unit/ CommentLinkBuilderTest.php - Data provider for ::testCommentLinkBuilder.
- comment_entity_view in core/
modules/ comment/ comment.module - Implements hook_entity_view().
File
-
core/
modules/ views/ src/ Plugin/ views/ style/ Rss.php, line 21
Namespace
Drupal\views\Plugin\views\styleView source
class Rss extends StylePluginBase {
/**
* {@inheritdoc}
*/
protected $usesRowPlugin = TRUE;
public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
$url_options = [];
$input = $this->view
->getExposedInput();
if ($input) {
$url_options['query'] = $input;
}
$url_options['absolute'] = TRUE;
$url = $feed_url->setOptions($url_options)
->toString();
// Add the RSS icon to the view.
$this->view->feedIcons[] = [
'#theme' => 'feed_icon',
'#url' => $url,
'#title' => $title,
];
// Attach a link to the RSS feed, which is an alternate representation.
$build['#attached']['html_head_link'][][] = [
'rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => $title,
'href' => $url,
];
}
protected function defineOptions() {
$options = parent::defineOptions();
$options['description'] = [
'default' => '',
];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['description'] = [
'#type' => 'textfield',
'#title' => $this->t('RSS description'),
'#default_value' => $this->options['description'],
'#description' => $this->t('This will appear in the RSS feed itself.'),
'#maxlength' => 1024,
];
}
/**
* Return an array of additional XHTML elements to add to the channel.
*
* @return array
* A render array.
*/
protected function getChannelElements() {
return [];
}
/**
* Get RSS feed description.
*
* @return string
* The string containing the description with the tokens replaced.
*/
public function getDescription() {
$description = $this->options['description'];
// Allow substitutions from the first row.
$description = $this->tokenizeValue($description, 0);
return $description;
}
public function render() {
$rows = [];
// This will be filled in by the row plugin and is used later on in the
// theming output.
$this->namespaces = [
'xmlns:dc' => 'http://purl.org/dc/elements/1.1/',
];
// Fetch any additional elements for the channel and merge in their
// namespaces.
$this->channel_elements = $this->getChannelElements();
foreach ($this->channel_elements as $element) {
if (isset($element['namespace'])) {
$this->namespaces = array_merge($this->namespaces, $element['namespace']);
}
}
foreach ($this->view->result as $row_index => $row) {
$this->view->row_index = $row_index;
$rows[] = $this->view->rowPlugin
->render($row);
}
$build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#rows' => $rows,
];
unset($this->view->row_index);
return $build;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.