function template_preprocess_views_view_row_rss

Same name in other branches
  1. 9 core/modules/views/views.theme.inc \template_preprocess_views_view_row_rss()
  2. 10 core/modules/views/views.theme.inc \template_preprocess_views_view_row_rss()
  3. 11.x core/modules/views/views.theme.inc \template_preprocess_views_view_row_rss()

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/views.theme.inc, line 910

Code

function template_preprocess_views_view_row_rss(&$variables) {
    $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) \Drupal::service('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.