Issue #1843762 by joelpittet, Albert Volkman, shrop: Convert views/templates/views-view-summary.tpl.php to twig.

8.0.x
Alex Pott 2013-05-24 10:28:53 -07:00
parent d39eace47f
commit 80cb1e4693
3 changed files with 48 additions and 26 deletions

View File

@ -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>

View File

@ -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>

View File

@ -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';