template_preprocess_views_view_row_rss

template_preprocess_views_view_row_rss(&$variables)

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 903
Preprocessors and helper functions to make theming easier.

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'] = array();
  foreach ($item->elements as $element) {
    if (isset($element['attributes']) && is_array($element['attributes'])) {
      $element['attributes'] = new Attribute($element['attributes']);
    }
    $variables['item_elements'][] = $element;
  }
}
doc_Drupal
2016-10-29 09:46:52
Comments
Leave a Comment

Please login to continue.