From 6d1774c7dd03b2aeb21e32311a56d7fd4e1a8736 Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Thu, 17 Dec 2009 19:14:42 +0000 Subject: [PATCH] - Patch #658314 by dereine, bleen18: fxed variable in node.tpl.php is buggy. --- modules/blog/blog.module | 2 +- modules/comment/comment.module | 3 +-- modules/forum/forum.module | 2 +- modules/node/node.api.php | 2 +- modules/node/node.module | 13 ++++++++++++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 216740f6994e..712eb9050363 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -67,7 +67,7 @@ function blog_form($node, $form_state) { * Implements hook_view(). */ function blog_view($node, $build_mode) { - if ((bool)menu_get_object()) { + if (node_is_page($node)) { // Breadcrumb navigation. drupal_set_breadcrumb(array(l(t('Home'), NULL), l(t('Blogs'), 'blog'), l(t("!name's blog", array('!name' => format_username($node))), 'blog/' . $node->uid))); } diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 9f018dba8b5e..ad21c374ca18 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -577,8 +577,7 @@ function comment_node_view($node, $build_mode) { // page. We compare $node and $page_node to ensure that comments are not // appended to other nodes shown on the page, for example a node_reference // displayed in 'full' build mode within another node. - $page_node = menu_get_object(); - if ($node->comment && isset($page_node->nid) && $page_node->nid == $node->nid && empty($node->in_preview) && user_access('access comments')) { + if ($node->comment && node_is_page($node) && empty($node->in_preview) && user_access('access comments')) { $node->content['comments'] = comment_node_page_additions($node); } } diff --git a/modules/forum/forum.module b/modules/forum/forum.module index cc9a4605c394..2ee98f936782 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -239,7 +239,7 @@ function forum_node_view($node, $build_mode) { $vid = variable_get('forum_nav_vocabulary', 0); $vocabulary = taxonomy_vocabulary_load($vid); if (_forum_node_check_node_type($node)) { - if ((bool)menu_get_object()) { + if (node_is_page($node)) { // Breadcrumb navigation $breadcrumb[] = l(t('Home'), NULL); $breadcrumb[] = l($vocabulary->name, 'forum'); diff --git a/modules/node/node.api.php b/modules/node/node.api.php index 6553dab6f63e..9a526c81998b 100644 --- a/modules/node/node.api.php +++ b/modules/node/node.api.php @@ -999,7 +999,7 @@ function hook_validate($node, &$form) { * For a detailed usage example, see node_example.module. */ function hook_view($node, $build_mode = 'full') { - if ((bool)menu_get_object()) { + if (node_is_page($node)) { $breadcrumb = array(); $breadcrumb[] = array('path' => 'example', 'title' => t('example')); $breadcrumb[] = array('path' => 'example/' . $node->field1, diff --git a/modules/node/node.module b/modules/node/node.module index a55fd039a94f..19ca4519be46 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1325,6 +1325,17 @@ function node_show($node, $message = FALSE) { return node_build_multiple(array($node->nid => $node), 'full'); } +/** + * Returns whether the current page is the full page view of the passed in node. + * + * @param $node + * A node object. + */ +function node_is_page($node) { + $page_node = menu_get_object(); + return (empty($page_node) ? $page_node->nid == $node->nid : FALSE); +} + /** * Process variables for node.tpl.php * @@ -1350,7 +1361,7 @@ function template_preprocess_node(&$variables) { $variables['name'] = theme('username', array('account' => $node)); $variables['node_url'] = url('node/' . $node->nid); $variables['node_title'] = check_plain($node->title[LANGUAGE_NONE][0]['value']); - $variables['page'] = (bool)menu_get_object(); + $variables['page'] = node_is_page($node); if (!empty($node->in_preview)) { unset($node->content['links']); -- GitLab