Commit 57178612 authored by alexpott's avatar alexpott

Issue #1843754 by joelpittet, shanethehat: Convert views/templates/views-view-list.tpl.php to twig.

parent 68803482
{#
/**
* @file
* Default theme implementation for a view template to display a list of rows.
*
* Available variables:
* - rows: A list of rows for this list.
* - row_classes: The row's HTML attributes correlating with the row's 'id'.
* - title: The title of this group of rows. May be empty.
* - list: @todo.
* - type: Starting tag will be either a ul or ol.
* - attributes: HTML attributes for the list element.
*
* @see template_preprocess()
* @see template_preprocess_views_view_list()
*
* @ingroup themeable
*/
#}
{% if wrapper_attributes -%}
<div{{ wrapper_attributes }}>
{% endif %}
{% if title %}
<h3>{{ title }}</h3>
{% endif %}
{% if list.type == 'ul' %}
<ul{{ list.attributes }}>
{% else %}
<ol{{ list.attributes }}>
{% endif %}
{% for id, row in rows %}
<li{{ row_classes[id] }}>{{ row }}</li>
{% endfor %}
{% if list.type == 'ul' %}
</ul>
{% else %}
</ol>
{% endif %}
{% if wrapper_attributes -%}
</div>
{% endif %}
<?php
/**
* @file
* Default simple view template to display a list of rows.
*
* - $title : The title of this group of rows. May be empty.
* - $options['type'] will either be ul or ol.
* @ingroup views_templates
*/
?>
<?php print $wrapper_prefix; ?>
<?php if (!empty($title)) : ?>
<h3><?php print $title; ?></h3>
<?php endif; ?>
<?php print $list_type_prefix; ?>
<?php foreach ($rows as $id => $row): ?>
<li <?php print $row_classes[$id]; ?>><?php print $row; ?></li>
<?php endforeach; ?>
<?php print $list_type_suffix; ?>
<?php print $wrapper_suffix; ?>
...@@ -829,10 +829,16 @@ function template_preprocess_views_view_unformatted(&$vars) { ...@@ -829,10 +829,16 @@ function template_preprocess_views_view_unformatted(&$vars) {
} }
/** /**
* Display the view as an HTML list element * Prepares variables for Views HTML list templates.
*
* Default template: views-view-list.html.twig.
*
* @param array $variables
* An associative array containing:
* - view: A View object.
*/ */
function template_preprocess_views_view_list(&$vars) { function template_preprocess_views_view_list(&$variables) {
$handler = $vars['view']->style_plugin; $handler = $variables['view']->style_plugin;
// Fetch classes from handler options. // Fetch classes from handler options.
$class = explode(' ', $handler->options['class']); $class = explode(' ', $handler->options['class']);
...@@ -842,20 +848,16 @@ function template_preprocess_views_view_list(&$vars) { ...@@ -842,20 +848,16 @@ function template_preprocess_views_view_list(&$vars) {
$wrapper_class = explode(' ', $handler->options['wrapper_class']); $wrapper_class = explode(' ', $handler->options['wrapper_class']);
$wrapper_class = array_map('drupal_clean_css_identifier', $wrapper_class); $wrapper_class = array_map('drupal_clean_css_identifier', $wrapper_class);
// Initialize a new attribute class for $class.
$attributes = new Attribute(array('class' => $class));
// Initialize a new attribute class for $wrapper_class. // Initialize a new attribute class for $wrapper_class.
if ($wrapper_class) { if ($wrapper_class) {
$wrapper_class = new Attribute(array('class' => $wrapper_class)); $variables['wrapper_attributes'] = new Attribute(array('class' => $wrapper_class));
$vars['wrapper_prefix'] = '<div' . $wrapper_class . '>';
$vars['wrapper_suffix'] = '</div>';
} }
$vars['list_type_prefix'] = '<' . $handler->options['type'] . $attributes . '>'; // Initialize a new attribute class for $class.
$vars['list_type_suffix'] = '</' . $handler->options['type'] . '>'; $variables['list']['attributes'] = new Attribute(array('class' => $class));
$variables['list']['type'] = $handler->options['type'];
template_preprocess_views_view_unformatted($vars); template_preprocess_views_view_unformatted($variables);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment