class Rss
Same name in this branch
- 9 core/modules/views/src/Plugin/views/style/Rss.php \Drupal\views\Plugin\views\style\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
Performs a node_view on the resulting object and formats it as an RSS item.
Plugin annotation
@ViewsRow(
id = "node_rss",
title = @Translation("Content"),
help = @Translation("Display the content with standard node view."),
theme = "views_view_row_rss",
register_theme = FALSE,
base = {"node_field_data"},
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\row\RowPluginBase extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\row\RssPluginBase extends \Drupal\views\Plugin\views\row\RowPluginBase
- class \Drupal\node\Plugin\views\row\Rss extends \Drupal\views\Plugin\views\row\RssPluginBase
- class \Drupal\views\Plugin\views\row\RssPluginBase extends \Drupal\views\Plugin\views\row\RowPluginBase
- class \Drupal\views\Plugin\views\row\RowPluginBase 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
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/ node/ src/ Plugin/ views/ row/ Rss.php, line 20
Namespace
Drupal\node\Plugin\views\rowView source
class Rss extends RssPluginBase {
/**
* The base table for this row plugin.
*
* @var string
*/
public $base_table = 'node_field_data';
/**
* The base field for this row plugin.
*
* @var string
*/
public $base_field = 'nid';
/**
* Stores the nodes loaded with preRender.
*
* @var array
*/
public $nodes = [];
/**
* {@inheritdoc}
*/
protected $entityTypeId = 'node';
/**
* {@inheritdoc}
*/
public function buildOptionsForm_summary_options() {
$options = parent::buildOptionsForm_summary_options();
$options['title'] = $this->t('Title only');
$options['default'] = $this->t('Use site default RSS settings');
return $options;
}
public function summaryTitle() {
$options = $this->buildOptionsForm_summary_options();
return $options[$this->options['view_mode']];
}
public function preRender($values) {
$nids = [];
foreach ($values as $row) {
$nids[] = $row->{$this->field_alias};
}
if (!empty($nids)) {
$this->nodes = $this->entityTypeManager
->getStorage('node')
->loadMultiple($nids);
}
}
public function render($row) {
global $base_url;
$nid = $row->{$this->field_alias};
if (!is_numeric($nid)) {
return;
}
$display_mode = $this->options['view_mode'];
if ($display_mode == 'default') {
$display_mode = \Drupal::config('system.rss')->get('items.view_mode');
}
// Load the specified node:
/** @var \Drupal\node\NodeInterface $node */
$node = $this->nodes[$nid];
if (empty($node)) {
return;
}
$node->rss_namespaces = [];
$node->rss_elements = [
[
'key' => 'pubDate',
'value' => gmdate('r', $node->getCreatedTime()),
],
[
'key' => 'dc:creator',
'value' => $node->getOwner()
->getDisplayName(),
],
[
'key' => 'guid',
'value' => $node->id() . ' at ' . $base_url,
'attributes' => [
'isPermaLink' => 'false',
],
],
];
// The node gets built and modules add to or modify $node->rss_elements
// and $node->rss_namespaces.
$build_mode = $display_mode;
$build = \Drupal::entityTypeManager()->getViewBuilder('node')
->view($node, $build_mode);
unset($build['#theme']);
if (!empty($node->rss_namespaces)) {
$this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $node->rss_namespaces);
}
$item = new \stdClass();
if ($display_mode != 'title') {
// We render node contents.
$item->description = $build;
}
$item->title = $node->label();
$item->link = $node->toUrl('canonical', [
'absolute' => TRUE,
])
->toString();
// Provide a reference so that the render call in
// template_preprocess_views_view_row_rss() can still access it.
$item->elements =& $node->rss_elements;
$item->nid = $node->id();
$build = [
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#row' => $item,
];
return $build;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.