summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-05-24 16:52:00 (GMT)
committerAlex Pott2013-05-24 16:52:00 (GMT)
commit8f7dc88de3aef56b4ffc3f3d062c401cfc8a1720 (patch)
tree91935a148cf5f7fae9ffdd18d09f362cc577ce56
parentb171982fe396a87fb902ced04a173193035ac769 (diff)
Issue #1898460 by pixelmord, bstoppel, steveoliver, jenlampton, johnnygamba, jastraat, Cottser, lbainbridge, myke, thedavidmeister, c4rl, joelpittet, ezeedub: Convert taxonomy module to Twig.
-rw-r--r--core/modules/taxonomy/taxonomy.module18
-rw-r--r--core/modules/taxonomy/templates/taxonomy-term.html.twig42
-rw-r--r--core/modules/taxonomy/templates/taxonomy-term.tpl.php49
3 files changed, 57 insertions, 52 deletions
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 2557008..c531daf 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -452,7 +452,18 @@ function taxonomy_term_view_multiple(array $terms, $view_mode = 'full', $langcod
}
/**
- * Process variables for taxonomy-term.tpl.php.
+ * Prepares variables for taxonomy term templates.
+ *
+ * Default template: taxonomy-term.html.twig.
+ *
+ * @param array $variables
+ * An associative array containing:
+ * - elements: An associative array containing the taxonomy term and any
+ * fields attached to the term. Properties used:
+ * - #term: The term object.
+ * - #view_mode: The current view mode for this taxonomy term, e.g.
+ * 'full' or 'teaser'.
+ * - attributes: HTML attributes for the containing element.
*/
function template_preprocess_taxonomy_term(&$variables) {
$variables['view_mode'] = $variables['elements']['#view_mode'];
@@ -461,8 +472,9 @@ function template_preprocess_taxonomy_term(&$variables) {
$uri = $term->uri();
$variables['url'] = url($uri['path'], $uri['options']);
- $variables['label'] = check_plain($term->label());
- $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term);
+ // We use name here because that is what appears in the UI.
+ $variables['name'] = check_plain($term->label());
+ $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term);
// Helpful $content variable for templates.
$variables['content'] = array();
diff --git a/core/modules/taxonomy/templates/taxonomy-term.html.twig b/core/modules/taxonomy/templates/taxonomy-term.html.twig
new file mode 100644
index 0000000..765cbcf
--- /dev/null
+++ b/core/modules/taxonomy/templates/taxonomy-term.html.twig
@@ -0,0 +1,42 @@
+{#
+/**
+ * @file
+ * Default theme implementation to display a taxonomy term.
+ *
+ * Available variables:
+ * - url: URL of the current term.
+ * - name: Name of the current term.
+ * - content: Items for the content of the term (fields and description).
+ * Use 'content' to print them all, or print a subset such as
+ * 'content.description'. Use the following code to temporarily suppress the
+ * printing of a given element:
+ * @code
+ * {% hide(content.description) %}
+ * @endcode
+ * - attributes: HTML attributes for the wrapper. The 'class' attribute
+ * contains the following classes by default:
+ * - taxonomy-term: The current template type, i.e. "theming hook".
+ * - vocabulary-[vocabulary-name]: The vocabulary that this term belongs to.
+ * For example, if the term belongs to a vocabulary called "Tags" then the
+ * class would be "vocabulary-tags".
+ * - page: Flag for the full page state.
+ * - term: The taxonomy term entity, including:
+ * - id: The ID of the taxonomy term.
+ * - view_mode: View mode, e.g. 'full', 'teaser', etc.
+ *
+ * @see template_preprocess()
+ * @see template_preprocess_taxonomy_term()
+ *
+ * @ingroup themeable
+ */
+#}
+<div id="taxonomy-term-{{ term.id }}"{{ attributes }}>
+ {{ title_prefix }}
+ {% if not page %}
+ <h2><a href="{{ url }}">{{ name }}</a></h2>
+ {% endif %}
+ {{ title_suffix }}
+ <div class="content">
+ {{ content }}
+ </div>
+</div>
diff --git a/core/modules/taxonomy/templates/taxonomy-term.tpl.php b/core/modules/taxonomy/templates/taxonomy-term.tpl.php
deleted file mode 100644
index a7e58f6..0000000
--- a/core/modules/taxonomy/templates/taxonomy-term.tpl.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-/**
- * @file
- * Default theme implementation to display a term.
- *
- * Available variables:
- * - $content: An array of items for the content of the term (fields and
- * description). Use render($content) to print them all, or print a subset
- * such as render($content['field_example']). Use
- * hide($content['field_example']) to temporarily suppress the printing of a
- * given element.
- * - $url: Direct url of the current term.
- * - $label: Name of the current term.
- * - $attributes: An instance of Attributes class that can be manipulated as an
- * array and printed as a string.
- * It includes the 'class' information, which includes:
- * - taxonomy-term: The current template type, i.e., "theming hook".
- * - vocabulary-[vocabulary-name]: The vocabulary to which the term belongs to.
- * For example, if the term is a "Tag" it would result in "vocabulary-tag".
- *
- * Other variables:
- * - $term: Full term object. Contains data that may not be safe.
- * - $view_mode: View mode, e.g. 'full', 'teaser'...
- * - $page: Flag for the full page state.
- * - $is_front: Flags true when presented in the front page.
- * - $logged_in: Flags true when the current user is a logged-in member.
- * - $is_admin: Flags true when the current user is an administrator.
- *
- * @see template_preprocess()
- * @see template_preprocess_taxonomy_term()
- * @see template_process()
- *
- * @ingroup themeable
- */
-?>
-<div id="taxonomy-term-<?php print $term->id(); ?>"<?php print $attributes; ?>>
-
- <?php print render($title_prefix); ?>
- <?php if (!$page): ?>
- <h2><a href="<?php print $url; ?>"><?php print $label; ?></a></h2>
- <?php endif; ?>
- <?php print render($title_suffix); ?>
-
- <div class="content">
- <?php print render($content); ?>
- </div>
-
-</div>