function template_preprocess_views_view_rss
Same name in other branches
- 9 core/modules/views/views.theme.inc \template_preprocess_views_view_rss()
- 8.9.x core/modules/views/views.theme.inc \template_preprocess_views_view_rss()
- 11.x core/modules/views/views.theme.inc \template_preprocess_views_view_rss()
Prepares variables for RSS feed templates.
Default template: views-view-rss.html.twig.
Parameters
array $variables: An associative array containing:
- view: A ViewExecutable object.
- rows: The raw row data.
File
-
core/
modules/ views/ views.theme.inc, line 904
Code
function template_preprocess_views_view_rss(&$variables) {
$view = $variables['view'];
$items = $variables['rows'];
$style = $view->style_plugin;
$config = \Drupal::config('system.site');
// The RSS 2.0 "spec" doesn't indicate HTML can be used in the description.
// We strip all HTML tags, but need to prevent double encoding from properly
// escaped source data (such as & becoming &).
$variables['description'] = Html::decodeEntities(strip_tags($style->getDescription()));
if ($view->display_handler
->getOption('sitename_title')) {
$title = $config->get('name');
if ($slogan = $config->get('slogan')) {
$title .= ' - ' . $slogan;
}
}
else {
$title = $view->getTitle();
}
$variables['title'] = $title;
$variables['link'] = Url::fromRoute('<front>')->setAbsolute()
->toString();
$variables['langcode'] = \Drupal::languageManager()->getCurrentLanguage()
->getId();
$variables['namespaces'] = new Attribute($style->namespaces);
$variables['items'] = $items;
$variables['channel_elements'] = $style->channel_elements;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.