Issue #1843764 by joelpittet, Cottser, dmouse, shanethehat, jwilson3: Convert views/templates/views-view-summary-unformatted.tpl.php to twig.

8.0.x
Alex Pott 2013-05-24 10:34:06 -07:00
parent ed042be06c
commit e7d739a6ea
3 changed files with 54 additions and 28 deletions

View File

@ -0,0 +1,34 @@
{#
/**
* @file
* Default theme implementation for unformatted summary links.
*
* Available variables:
* - rows: The rows contained in this view.
* - url: The URL to this row's content.
* - count: The number of items this summary item represents.
* - separator: A separator between each row.
* - row_classes: HTML attributes for a row, either containing an 'active' class
* or no attributes, that correlate to each row by ID.
* - options: Flags indicating how each row should be displayed. This contains:
* - count: A flag indicating whether the row's 'count' should be displayed.
* - inline: A flag indicating whether the item should be wrapped in an inline
* or block level HTML element.
*
* @see template_preprocess()
* @see template_preprocess_views_view_summary_unformatted()
*
* @ingroup themeable
*/
#}
{% for id, row in rows %}
{{ options.inline ? '<span' : '<div' }} class="views-summary views-summary-unformatted">
{% if row.separator -%}
{{ row.separator }}
{%- endif %}
<a href="{{ row.url }}"{{ row_classes[id] }}>{{ row.link }}</a>
{% if options.count %}
({{ row.count }})
{% endif %}
{{ options.inline ? '</span>' : '</div>' }}
{% endfor %}

View File

@ -1,20 +0,0 @@
<?php
/**
* @file
* Default simple view template to display a group of summary lines.
*
* This wraps items in a span if set to inline, or a div if not.
*
* @ingroup views_templates
*/
?>
<?php foreach ($rows as $id => $row): ?>
<?php print (!empty($options['inline']) ? '<span' : '<div') . ' class="views-summary views-summary-unformatted">'; ?>
<?php if (!empty($row->separator)): ?><? print $row->separator; ?><?php endif; ?>
<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; ?>
<?php print !empty($options['inline']) ? '</span>' : '</div>'; ?>
<?php endforeach; ?>

View File

@ -396,11 +396,20 @@ function template_preprocess_views_view_summary(&$vars) {
}
/**
* Template preprocess theme function to print summary basically
* unformatted.
* Prepares variables for unformatted summary view templates.
*
* Default template: views-view-summary-unformatted.html.twig.
*
* @param array $vars
* An associative array containing:
* - view: A ViewExecutable object.
* - rows: The raw row data.
* - options: An array of options. Each option contains:
* - separator: A string to be placed between inline fields to keep them
* visually distinct.
*/
function template_preprocess_views_view_summary_unformatted(&$vars) {
$view = $vars['view'];
$view = $vars['view'];
$argument = $view->argument[$view->build_info['summary_level']];
$vars['row_classes'] = array();
@ -412,12 +421,15 @@ function template_preprocess_views_view_summary_unformatted(&$vars) {
$count = 0;
$active_urls = drupal_map_assoc(array(
url(current_path(), array('alias' => TRUE)), // force system path
url(current_path()), // could be an alias
// Force system path.
url(current_path(), array('alias' => TRUE)),
// Could be an alias.
url(current_path()),
));
// 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 for each 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) {
$row_args[$id] = $argument->summary_argument($row);
@ -425,7 +437,7 @@ function template_preprocess_views_view_summary_unformatted(&$vars) {
$argument->process_summary_arguments($row_args);
foreach ($vars['rows'] as $id => $row) {
// only false on first time:
// Only false on first time.
if ($count++) {
$vars['rows'][$id]->separator = filter_xss_admin($vars['options']['separator']);
}