template_preprocess_views_view_opml

template_preprocess_views_view_opml(&$variables)

Prepares variables for OPML feed templates.

Default template: views-view-opml.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 935
Preprocessors and helper functions to make theming easier.

Code

function template_preprocess_views_view_opml(&$variables) {
  $view = $variables['view'];
  $items = $variables['rows'];

  $config = \Drupal::config('system.site');

  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['items'] = $items;
  $variables['updated'] = gmdate(DATE_RFC2822, REQUEST_TIME);

  // During live preview we don't want to output the header since the contents
  // of the feed are being displayed inside a normal HTML page.
  if (empty($variables['view']->live_preview)) {
    $variables['view']->getResponse()->headers->set('Content-Type', 'text/xml; charset=utf-8');
  }
}
doc_Drupal
2016-10-29 09:46:52
Comments
Leave a Comment

Please login to continue.