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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.