function template_preprocess_views_view_opml in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/views.theme.inc \template_preprocess_views_view_opml()
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 893 - 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');
}
}