summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-05-24 17:22:36 (GMT)
committerAlex Pott2013-05-24 17:22:36 (GMT)
commita312df8cda5115f4d97781366aaf48b083817c91 (patch)
treefb7e502e0c1964ffab7e041d482022ed1de5a626
parent7016229fc1ccf1cd449e5f12312a3889dba5ac67 (diff)
Issue #1843760 by webthingee, joelpittet, jpamental: Convert views/templates/views-view-rss.tpl.php to twig.
-rw-r--r--core/modules/views/templates/views-view-rss.html.twig31
-rw-r--r--core/modules/views/templates/views-view-rss.tpl.php20
-rw-r--r--core/modules/views/views.theme.inc25
3 files changed, 47 insertions, 29 deletions
diff --git a/core/modules/views/templates/views-view-rss.html.twig b/core/modules/views/templates/views-view-rss.html.twig
new file mode 100644
index 0000000..d223b05
--- /dev/null
+++ b/core/modules/views/templates/views-view-rss.html.twig
@@ -0,0 +1,31 @@
+{#
+/**
+ * @file
+ * Default template for feed displays that use the RSS style.
+ *
+ * Available variables:
+ * - link: The link to the feed (the view path).
+ * - namespaces: The XML namespaces (added automatically).
+ * - title: The title of the feed (as set in the view).
+ * - description: The feed description (from feed settings).
+ * - langcode: The language encoding.
+ * - channel_elements: The formatted channel elements.
+ * - items: The feed items themselves.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_views_view_rss()
+ *
+ * @ingroup themeable
+ */
+#}
+<?xml version="1.0" encoding="utf-8" ?>
+<rss version="2.0" xml:base="{{ link }}"{{ namespaces }}>
+ <channel>
+ <title>{{ title }}</title>
+ <link>{{ link }}</link>
+ <description>{{ description }}</description>
+ <language>{{ langcode }}</language>
+ {{ channel_elements }}
+ {{ items }}
+ </channel>
+</rss>
diff --git a/core/modules/views/templates/views-view-rss.tpl.php b/core/modules/views/templates/views-view-rss.tpl.php
deleted file mode 100644
index 18ca73e..0000000
--- a/core/modules/views/templates/views-view-rss.tpl.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/**
- * @file
- * Default template for feed displays that use the RSS style.
- *
- * @ingroup views_templates
- */
-?>
-<?php print "<?xml"; ?> version="1.0" encoding="utf-8" <?php print "?>"; ?>
-<rss version="2.0" xml:base="<?php print $link; ?>"<?php print $namespaces; ?>>
- <channel>
- <title><?php print $title; ?></title>
- <link><?php print $link; ?></link>
- <description><?php print $description; ?></description>
- <language><?php print $langcode; ?></language>
- <?php print $channel_elements; ?>
- <?php print $items; ?>
- </channel>
-</rss>
diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc
index e17f44f..d3c0a13 100644
--- a/core/modules/views/views.theme.inc
+++ b/core/modules/views/views.theme.inc
@@ -846,16 +846,22 @@ function template_preprocess_views_view_list(&$vars) {
}
/**
- * Preprocess an RSS feed
- */
+ * Prepares variables for RSS feed templates.
+ *
+ * Default template: views-view-rss.html.twig.
+ *
+ * @param array $vars
+ * An associative array containing:
+ * - view: A ViewExecutable object.
+ * - rows: The raw row data.
+*/
function template_preprocess_views_view_rss(&$vars) {
global $base_url;
- $view = &$vars['view'];
- $options = &$vars['options'];
- $items = &$vars['rows'];
+ $view = $vars['view'];
+ $items = $vars['rows'];
- $style = &$view->style_plugin;
+ $style = $view->style_plugin;
$config = config('system.site');
@@ -875,8 +881,8 @@ function template_preprocess_views_view_rss(&$vars) {
}
$vars['title'] = check_plain($title);
- // Figure out which display which has a path we're using for this feed. If there isn't
- // one, use the global $base_url
+ // Figure out which display which has a path we're using for this feed. If
+ // there isn't one, use the global $base_url
$link_display_id = $view->display_handler->getLinkDisplay();
if ($link_display_id && $display = $view->displayHandlers->get($link_display_id)) {
$path = $view->displayHandlers->get($link_display_id)->getPath();
@@ -889,7 +895,8 @@ function template_preprocess_views_view_rss(&$vars) {
$url_options['query'] = $view->exposed_raw_input;
}
- // Compare the link to the default home page; if it's the default home page, just use $base_url.
+ // Compare the link to the default home page; if it's the default home page,
+ // just use $base_url.
if ($path == $config->get('page.front')) {
$path = '';
}