summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-05-24 17:28:53 (GMT)
committerAlex Pott2013-05-24 17:28:53 (GMT)
commit80cb1e46930198d20e78790ac98d98bbb337f23c (patch)
tree023a04be1acd4889c1c4982b675a38812144d5b5
parentd39eace47f5c339421cb04927a7e84f5abb4c3b9 (diff)
Issue #1843762 by joelpittet, Albert Volkman, shrop: Convert views/templates/views-view-summary.tpl.php to twig.
-rw-r--r--core/modules/views/templates/views-view-summary.html.twig34
-rw-r--r--core/modules/views/templates/views-view-summary.tpl.php20
-rw-r--r--core/modules/views/views.theme.inc20
3 files changed, 48 insertions, 26 deletions
diff --git a/core/modules/views/templates/views-view-summary.html.twig b/core/modules/views/templates/views-view-summary.html.twig
new file mode 100644
index 0000000..cffc2bc
--- /dev/null
+++ b/core/modules/views/templates/views-view-summary.html.twig
@@ -0,0 +1,34 @@
+{#
+/**
+ * @file
+ * Default theme implementation to display a list of summary lines.
+ *
+ * Available variables:
+ * - rows: The rows contained in this view.
+ * Each row contains:
+ * - url: The summary link URL.
+ * - link: The summary link text.
+ * - count: The number of items under this grouping.
+ * - row_classes: HTML classes to apply to each row, indexed by row ID.
+ * This matches the index in rows.
+ * - options: Flags indicating how the summary should be displayed.
+ * This contains:
+ * - count: A flag indicating whether the count should be displayed.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_views_view_summary()
+ *
+ * @ingroup themeable
+ */
+#}
+<div class="item-list">
+ <ul class="views-summary">
+ {% for id, row in rows %}
+ <li><a href="{{ row.url }}"{{ row_classes[id] }}>{{ row.link }}</a>
+ {% if options.count %}
+ ({{ row.count }})
+ {% endif %}
+ </li>
+ {% endfor %}
+ </ul>
+</div>
diff --git a/core/modules/views/templates/views-view-summary.tpl.php b/core/modules/views/templates/views-view-summary.tpl.php
deleted file mode 100644
index ce51e70..0000000
--- a/core/modules/views/templates/views-view-summary.tpl.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/**
- * @file
- * Default simple view template to display a list of summary lines.
- *
- * @ingroup views_templates
- */
-?>
-<div class="item-list">
- <ul class="views-summary">
- <?php foreach ($rows as $id => $row): ?>
- <li><a href="<?php print $row->url; ?>"<?php print $row_classes[$id]; ?>><?php print $row->link; ?></a>
- <?php if (!empty($options['count'])): ?>
- (<?php print $row->count?>)
- <?php endif; ?>
- </li>
- <?php endforeach; ?>
- </ul>
-</div>
diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc
index 88499b3..21de05c 100644
--- a/core/modules/views/views.theme.inc
+++ b/core/modules/views/views.theme.inc
@@ -328,10 +328,19 @@ function template_preprocess_views_view_field(&$vars) {
}
/**
- * Preprocess theme function to print a single record from a row, with fields
+ * Prepares variables for views summary templates.
+ *
+ * The summary prints a single record from a row, with fields.
+ *
+ * Default template: views-view-summary.html.twig.
+ *
+ * @param array $vars
+ * An associative array containing:
+ * - view: A ViewExecutable object.
+ * - rows: The raw row data.
*/
function template_preprocess_views_view_summary(&$vars) {
- $view = $vars['view'];
+ $view = $vars['view'];
$argument = $view->argument[$view->build_info['summary_level']];
$vars['row_classes'] = array();
@@ -346,8 +355,9 @@ function template_preprocess_views_view_summary(&$vars) {
url(current_path()), // could be an alias
));
- // Collect all arguments foreach row, to be able to alter them for example by the validator.
- // This is not done per single argument value, because this could cause performance problems.
+ // Collect all arguments foreach row, to be able to alter them for example
+ // by the validator. This is not done per single argument value, because this
+ // could cause performance problems.
$row_args = array();
foreach ($vars['rows'] as $id => $row) {
@@ -356,7 +366,6 @@ function template_preprocess_views_view_summary(&$vars) {
$argument->process_summary_arguments($row_args);
foreach ($vars['rows'] as $id => $row) {
-
$vars['rows'][$id]->link = $argument->summary_name($row);
$args = $view->args;
$args[$argument->position] = $row_args[$id];
@@ -367,7 +376,6 @@ function template_preprocess_views_view_summary(&$vars) {
}
$vars['rows'][$id]->url = url($view->getUrl($args, $base_path), $url_options);
$vars['rows'][$id]->count = intval($row->{$argument->count_alias});
-
$vars['row_classes'][$id] = array();
if (isset($active_urls[$vars['rows'][$id]->url])) {
$vars['row_classes'][$id]['class'][] = 'active';