function ViewsThemeHooks::preprocessViewsViewRowRss
Prepares variables for views RSS item templates.
Default template: views-view-row-rss.html.twig.
Parameters
array $variables: An associative array containing:
- row: The raw results rows.
File
-
core/
modules/ views/ src/ Hook/ ViewsThemeHooks.php, line 1170
Class
- ViewsThemeHooks
- Hook implementations for views.
Namespace
Drupal\views\HookCode
public function preprocessViewsViewRowRss(array &$variables) : void {
$item = $variables['row'];
$variables['title'] = $item->title;
$variables['link'] = $item->link;
// The description is the only place where we should find HTML.
// @see https://validator.w3.org/feed/docs/rss2.html#hrelementsOfLtitemgt
// If we have a render array, render it here and pass the result to the
// template, letting Twig autoescape it.
if (isset($item->description) && is_array($item->description)) {
$variables['description'] = (string) $this->renderer
->render($item->description);
}
$variables['item_elements'] = [];
foreach ($item->elements as $element) {
if (isset($element['attributes']) && is_array($element['attributes'])) {
$element['attributes'] = new Attribute($element['attributes']);
}
$variables['item_elements'][] = $element;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.