Created
October 12, 2012 17:24
-
-
Save webchick/3880359 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- node.tpl.php 2012-10-12 10:22:00.000000000 -0700 | |
+++ node.twig 2012-10-12 10:23:20.000000000 -0700 | |
@@ -1,24 +1,23 @@ | |
-<?php | |
- | |
+{# | |
/** | |
* @file | |
* Default theme implementation to display a node. | |
* | |
* Available variables: | |
- * - $label: the (sanitized) title of the node. | |
- * - $content: An array of node items. 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. | |
- * - $user_picture: The node author's picture from user-picture.tpl.php. | |
- * - $date: Formatted creation date. Preprocess functions can reformat it by | |
+ * - label: the (sanitized) title of the node. | |
+ * - content: An array of node items. Use {{ content }} to print them all, | |
+ * or print a subset such as {{ content.field_example }}. Use | |
+ * {% hide(content.field_example) %} to temporarily suppress the printing | |
+ * of a given element. | |
+ * - user_picture: The node author's picture from user-picture.twig. | |
+ * - date: Formatted creation date. Preprocess functions can reformat it by | |
* calling format_date() with the desired parameters on the $created variable. | |
- * - $name: Themed username of node author output from theme_username(). | |
- * - $node_url: Direct URL of the current node. | |
- * - $display_submitted: Whether submission information should be displayed. | |
- * - $submitted: Submission information created from $name and $date during | |
+ * - name: Themed username of node author output from theme_username(). | |
+ * - node_url: Direct URL of the current node. | |
+ * - display_submitted: Whether submission information should be displayed. | |
+ * - submitted: Submission information created from $name and $date during | |
* template_preprocess_node(). | |
- * - $attributes: An instance of Attributes class that can be manipulated as an | |
+ * - 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: | |
* - node: The current template type; for example, "theming hook". | |
@@ -33,39 +32,37 @@ | |
* - sticky: Nodes ordered above other non-sticky nodes in teaser | |
* listings. | |
* - unpublished: Unpublished nodes visible only to administrators. | |
- * - $title_prefix (array): An array containing additional output populated by | |
- * modules, intended to be displayed in front of the main title tag that | |
- * appears in the template. | |
- * - $title_suffix (array): An array containing additional output populated by | |
- * modules, intended to be displayed after the main title tag that appears in | |
- * the template. | |
+ * - title_prefix: Additional output populated by modules, intended to be | |
+ * displayed in front of the main title tag that appears in the template. | |
+ * - title_suffix: Additional output populated by modules, intended to be | |
+ * displayed after the main title tag that appears in the template. | |
* | |
* Other variables: | |
- * - $node: Full node entity. Contains data that may not be safe. | |
- * - $type: Node type; for example, page, article, etc. | |
- * - $comment_count: Number of comments attached to the node. | |
- * - $uid: User ID of the node author. | |
- * - $created: Time the node was published formatted in Unix timestamp. | |
- * - $zebra: Outputs either "even" or "odd". Useful for zebra striping in | |
+ * - node: Full node entity. Contains data that may not be safe. | |
+ * - type: Node type; for example, page, article, etc. | |
+ * - comment_count: Number of comments attached to the node. | |
+ * - uid: User ID of the node author. | |
+ * - created: Time the node was published formatted in Unix timestamp. | |
+ * - zebra: Outputs either "even" or "odd". Useful for zebra striping in | |
* teaser listings. | |
- * - $id: Position of the node. Increments each time it's output. | |
+ * - id: Position of the node. Increments each time it's output. | |
* | |
* Node status variables: | |
- * - $view_mode: View mode; for example, "teaser" or "full". | |
- * - $teaser: Flag for the teaser state (shortcut for $view_mode == 'teaser'). | |
- * - $page: Flag for the full page state. | |
- * - $promote: Flag for front page promotion state. | |
- * - $sticky: Flags for sticky post setting. | |
- * - $status: Flag for published status. | |
- * - $comment: State of comment settings for the node. | |
- * - $readmore: Flags true if the teaser content of the node cannot hold the | |
+ * - view_mode: View mode; for example, "teaser" or "full". | |
+ * - teaser: Flag for the teaser state (shortcut for $view_mode == 'teaser'). | |
+ * - page: Flag for the full page state. | |
+ * - promote: Flag for front page promotion state. | |
+ * - sticky: Flags for sticky post setting. | |
+ * - status: Flag for published status. | |
+ * - comment: State of comment settings for the node. | |
+ * - readmore: Flags true if the teaser content of the node cannot hold the | |
* main body content. | |
- * - $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. | |
+ * - 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. | |
* | |
* Field variables: for each field instance attached to the node a corresponding | |
- * variable is defined; for example, $node->body becomes $body. When needing to | |
+ * variable is defined; for example, $node->body becomes body. When needing to | |
* access a field's raw values, developers/themers are strongly encouraged to | |
* use these variables. Otherwise they will have to explicitly specify the | |
* desired field language; for example, $node->body['en'], thus overriding any | |
@@ -73,36 +70,40 @@ | |
* | |
* @see template_preprocess() | |
* @see template_preprocess_node() | |
- * @see template_process() | |
* | |
* @ingroup themeable | |
*/ | |
-?> | |
-<article id="node-<?php print $node->nid; ?>" class="<?php print $attributes['class']; ?> clearfix"<?php print $attributes; ?>> | |
- | |
- <?php print render($title_prefix); ?> | |
- <?php if (!$page): ?> | |
- <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>" rel="bookmark"><?php print $label; ?></a></h2> | |
- <?php endif; ?> | |
- <?php print render($title_suffix); ?> | |
+#} | |
+{# | |
+ @todo: might be a good idea to remove the id attribute, because if that gets | |
+ rendered twice on a page this is invalid CSS | |
+ for example: two lists in different view modes. | |
+#} | |
+<article id="node-{{ node.nid }}" class="{{ attributes.class }} clearfix" {{- attributes }}> | |
+ | |
+ {{ title_prefix }} | |
+ {% if page != true %} | |
+ <h2 {{- title_attributes }}> | |
+ <a href="{{ node_url }}" rel="bookmark">{{ label }}</a> | |
+ </h2> | |
+ {% endif %} | |
+ {{ title_suffix }} | |
- <?php if ($display_submitted): ?> | |
+ {% if display_submitted %} | |
<footer> | |
- <?php print $user_picture; ?> | |
- <p class="submitted"><?php print $submitted; ?></p> | |
+ {{ user_picture }} | |
+ <p class="submitted">{{ submitted }}</p> | |
</footer> | |
- <?php endif; ?> | |
+ {% endif %} | |
- <div class="content"<?php print $content_attributes; ?>> | |
- <?php | |
- // We hide the comments and links now so that we can render them later. | |
- hide($content['comments']); | |
- hide($content['links']); | |
- print render($content); | |
- ?> | |
+ <div class="content" {{- content_attributes }}> | |
+ {# We hide the comments and links now so that we can render them later. #} | |
+ {{ hide(content.comments) }} | |
+ {{ hide(content.links) }} | |
+ {{ content }} | |
</div> | |
- <?php print render($content['links']); ?> | |
- <?php print render($content['comments']); ?> | |
+ {{ content.links }} | |
+ {{ content.comments }} | |
</article> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment