diff --git includes/common.inc includes/common.inc index 6b0138c..cfffcc9 100644 --- includes/common.inc +++ includes/common.inc @@ -3712,6 +3712,38 @@ function drupal_render_children(&$element, $children_keys = NULL) { } /** + * A brief alias for drupal_render(), to be used in templates. + * + * This always prints the top level element. Subsequent elements are only printed + * if they haven't been printed before or have been re-enabled with show(). + */ +function render(&$element) { + if (is_array($element)) { + show($element); + print drupal_render($element); + } + else { + print $element; + } +} + +/** + * Hide an element during rendering. + */ +function hide(&$element) { + $element['#printed'] = TRUE; + return $element; +} + +/** + * Show a hidden or already printed element during rendering. + */ +function show(&$element) { + $element['#printed'] = FALSE; + return $element; +} + +/** * Function used by uasort to sort structured arrays by weight. */ function element_sort($a, $b) { diff --git modules/node/node.module modules/node/node.module index 8c77488..30ad4e5 100644 --- modules/node/node.module +++ modules/node/node.module @@ -1358,18 +1358,6 @@ function template_preprocess_node(&$variables) { unset($node->content['links']); } - // Render taxonomy links separately. - $variables['terms'] = !empty($node->content['links']['terms']) ? drupal_render($node->content['links']['terms']) : ''; - - // Render all remaining node links. - $variables['links'] = !empty($node->content['links']) ? drupal_render($node->content['links']) : ''; - - // Render any comments. - $variables['comments'] = !empty($node->content['comments']) ? drupal_render($node->content['comments']) : ''; - - // Render the rest of the node into $content. - $variables['content'] = drupal_render($node->content); - // Flatten the node object's member fields. $variables = array_merge((array)$node, $variables); diff --git modules/node/node.tpl.php modules/node/node.tpl.php index 36ad041..5999ece 100644 --- modules/node/node.tpl.php +++ modules/node/node.tpl.php @@ -7,7 +7,9 @@ * * Available variables: * - $title: the (sanitized) title of the node. - * - $content: Node body or teaser depending on $teaser flag. + * - $content: An array of node items. Use render($content) to print them all, or + * print a subset such as render($content['field_example']). Always call + * render($content) at the end in order to print all remaining items. * - $comments: the themed list of comments (if any). * - $picture: The authors picture of the node output from * theme_user_picture(). @@ -64,6 +66,9 @@ * @see template_preprocess_node() * @see template_process() */ + +// Uncomment the line below to see what variables are available in this template. +// print '
' . check_plain(print_r(get_defined_vars(), TRUE)) . ''; ?>
'. check_plain(print_r($profile, 1)) .''; - * @endcode + * Use render($user_profile) to print all profile items, or print a subset + * such as render($content['field_example']). Always call render($user_profile) + * at the end in order to print all remaining items. If the item is a category, + * it will contain all it's profile items. By default, $user_profile['summary'] + * is provided which contains data on the user's history. Other data can be + * included by modules. $user_profile['user_picture'] is available + * for showing the account picture. * * @see user-profile-category.tpl.php * Where the html is handled for the group. @@ -36,14 +22,16 @@ * Where the html is handled for each item in the group. * * Available variables: - * - $user_profile: All user profile data. Ready for print. - * - $profile: Keyed array of profile categories and their items or other data - * provided by modules. + * - $user_profile: An array of profile items. Use dr() to print them. * - TODO D7 : document $FIELD_NAME_rendered variables. * * @see template_preprocess_user_profile() */ + +// Uncomment the line below to see what variables are available in this template. +// print '
' . check_plain(print_r(get_defined_vars(), TRUE)) . ''; + ?>