Commit dc98af82 authored by alexpott's avatar alexpott

Issue #1843748 by tlattimore, shanethehat, geoffreyr, Cottser, Hydra,...

Issue #1843748 by tlattimore, shanethehat, geoffreyr, Cottser, Hydra, joelpittet, widukind, c4rl, rcaracaus: Convert views/templates/views-view-fields.tpl.php to twig.
parent 94e3e87a
{#
/**
* @file
* Default view template to display all the fields in a row.
*
* Available variables:
* - view: The view in use.
* - fields: A list of fields, each one contains:
* - content: The output of the field.
* - raw: The raw data for the field, if it exists. This is NOT output safe.
* - class: The safe class ID to use.
* - handler: The Views field handler controlling this field.
* - inline: Whether or not the field should be inline.
* - inline_html: Either div or span based on the 'inline' flag.
* - wrapper_prefix: A complete wrapper containing the inline_html to use.
* - wrapper_suffix: The closing tag for the wrapper.
* - separator: An optional separator that may appear before a field.
* - label: The field's label text.
* - label_html: The full HTML of the label to use including configured
* element type.
* - row: The raw result from the query, with all data it fetched.
*
* @see template_preprocess()
* @see template_preprocess_views_view_fields()
*
* @ingroup themeable
*/
#}
<!--
THIS FILE IS NOT USED AND IS HERE AS A STARTING POINT FOR CUSTOMIZATION ONLY.
See http://api.drupal.org/api/function/theme_views_view_fields/8 for details.
After copying this file to your theme's folder and customizing it, remove this
HTML comment.
-->
{% for field in fields %}
{{ field.separator }}
{{ field.wrapper_prefix }}
{{ field.label_html }}
{{ field.content }}
{{ field.wrapper_suffix }}
{% endfor %}
<?php
/**
* @file
* Default simple view template to all the fields as a row.
*
* - $view: The view in use.
* - $fields: an array of $field objects. Each one contains:
* - $field->content: The output of the field.
* - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
* - $field->class: The safe class id to use.
* - $field->handler: The Views field handler object controlling this field. Do not use
* var_export to dump this object, as it can't handle the recursion.
* - $field->inline: Whether or not the field should be inline.
* - $field->inline_html: either div or span based on the above flag.
* - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
* - $field->wrapper_suffix: The closing tag for the wrapper.
* - $field->separator: an optional separator that may appear before a field.
* - $field->label: The wrap label text to use.
* - $field->label_html: The full HTML of the label to use including
* configured element type.
* - $row: The raw result object from the query, with all data it fetched.
*
* @ingroup views_templates
*/
?>
<?php foreach ($fields as $id => $field): ?>
<?php if (!empty($field->separator)): ?>
<?php print $field->separator; ?>
<?php endif; ?>
<?php print $field->wrapper_prefix; ?>
<?php print $field->label_html; ?>
<?php print $field->content; ?>
<?php print $field->wrapper_suffix; ?>
<?php endforeach; ?>
......@@ -175,7 +175,23 @@ function template_preprocess_views_view(&$vars) {
}
/**
* Preprocess theme function to print a single record from a row, with fields
* Prepares variables for views fields templates.
*
* Default template: views-view-fields.html.twig.
*
* @param array $vars
* An associative array containing:
* - view: The view object.
* - options: An array of options. Each option contains:
* - inline: An array that contains the fields that are to be
* displayed inline.
* - default_field_elements: If default field wrapper
* elements are to be provided.
* - hide_empty: Whether the field is to be hidden if empty.
* - element_default_classes: If the default classes are to be added.
* - separator: A string to be placed between inline fields to keep them
* visually distinct.
* - row: An array containing information about the current row.
*/
function template_preprocess_views_view_fields(&$vars) {
$view = $vars['view'];
......@@ -295,6 +311,39 @@ function template_preprocess_views_view_fields(&$vars) {
}
/**
* Returns HTML for multiple views fields.
*
* @param $variables
* An associative array containing:
* - fields: An array of field objects. Each field object contains:
* - separator: A string that separates the fields.
* - wrapper_suffix: A string added to the beginning of the fields.
* - label_html: An HTML string that labels the fields.
* - content: The fields.
* - wrapper_suffix: A string added to the end of the fields.
*
* @see template_preprocess_views_view_fields()
*/
function theme_views_view_fields($variables) {
$fields = $variables['fields'];
$output = '';
foreach ($fields as $id => $field) {
if (!empty($field->separator)) {
$output .= $field->separator;
}
$output .= $field->wrapper_prefix;
$output .= $field->label_html;
$output .= $field->content;
$output .= $field->wrapper_suffix;
}
return $output;
}
/**
* Prepares variables for views single grouping templates.
*
......
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