summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-05-25 00:03:24 (GMT)
committer Alex Pott2013-05-25 00:03:24 (GMT)
commitdc98af824297b924f39335ee2d2c7307640cdcb7 (patch)
tree17dea8a2f21f8d7a7bf2f02b621038f71a35acd7
parent94e3e87a4aef0c573dc053ebf127d88fb604ca8e (diff)
Issue #1843748 by tlattimore, shanethehat, geoffreyr, Cottser, Hydra, joelpittet, widukind, c4rl, rcaracaus: Convert views/templates/views-view-fields.tpl.php to twig.
-rw-r--r--core/modules/views/templates/views-view-fields.html.twig42
-rw-r--r--core/modules/views/templates/views-view-fields.tpl.php36
-rw-r--r--core/modules/views/views.theme.inc51
3 files changed, 92 insertions, 37 deletions
diff --git a/core/modules/views/templates/views-view-fields.html.twig b/core/modules/views/templates/views-view-fields.html.twig
new file mode 100644
index 0000000..38525c7
--- /dev/null
+++ b/core/modules/views/templates/views-view-fields.html.twig
@@ -0,0 +1,42 @@
+{#
+/**
+ * @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 %}
diff --git a/core/modules/views/templates/views-view-fields.tpl.php b/core/modules/views/templates/views-view-fields.tpl.php
deleted file mode 100644
index ae3a4c6..0000000
--- a/core/modules/views/templates/views-view-fields.tpl.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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; ?>
diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc
index 7b47475..82a4a1f 100644
--- a/core/modules/views/views.theme.inc
+++ b/core/modules/views/views.theme.inc
@@ -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'];
@@ -296,6 +312,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.
*
* Default template: views-view-grouping.html.twig.