- Patch #658314 by bleen18, dereine: fixed variable in node.tpl.php -- take 2.

merge-requests/26/head
Dries Buytaert 2009-12-22 20:38:23 +00:00
parent 86e806f2d8
commit 3d381a1c54
5 changed files with 16 additions and 6 deletions

View File

@ -67,7 +67,7 @@ function blog_form($node, $form_state) {
* Implements hook_view(). * Implements hook_view().
*/ */
function blog_view($node, $build_mode) { function blog_view($node, $build_mode) {
if ((bool)menu_get_object()) { if (node_is_page($node)) {
// Breadcrumb navigation. // 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))); 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)));
} }

View File

@ -577,8 +577,7 @@ function comment_node_view($node, $build_mode) {
// page. We compare $node and $page_node to ensure that comments are not // 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 // appended to other nodes shown on the page, for example a node_reference
// displayed in 'full' build mode within another node. // displayed in 'full' build mode within another node.
$page_node = menu_get_object(); if ($node->comment && node_is_page($node) && empty($node->in_preview) && user_access('access comments')) {
if ($node->comment && isset($page_node->nid) && $page_node->nid == $node->nid && empty($node->in_preview) && user_access('access comments')) {
$node->content['comments'] = comment_node_page_additions($node); $node->content['comments'] = comment_node_page_additions($node);
} }
} }

View File

@ -239,7 +239,7 @@ function forum_node_view($node, $build_mode) {
$vid = variable_get('forum_nav_vocabulary', 0); $vid = variable_get('forum_nav_vocabulary', 0);
$vocabulary = taxonomy_vocabulary_load($vid); $vocabulary = taxonomy_vocabulary_load($vid);
if (_forum_node_check_node_type($node)) { if (_forum_node_check_node_type($node)) {
if ((bool)menu_get_object()) { if (node_is_page($node)) {
// Breadcrumb navigation // Breadcrumb navigation
$breadcrumb[] = l(t('Home'), NULL); $breadcrumb[] = l(t('Home'), NULL);
$breadcrumb[] = l($vocabulary->name, 'forum'); $breadcrumb[] = l($vocabulary->name, 'forum');

View File

@ -999,7 +999,7 @@ function hook_validate($node, &$form) {
* For a detailed usage example, see node_example.module. * For a detailed usage example, see node_example.module.
*/ */
function hook_view($node, $build_mode = 'full') { function hook_view($node, $build_mode = 'full') {
if ((bool)menu_get_object()) { if (node_is_page($node)) {
$breadcrumb = array(); $breadcrumb = array();
$breadcrumb[] = array('path' => 'example', 'title' => t('example')); $breadcrumb[] = array('path' => 'example', 'title' => t('example'));
$breadcrumb[] = array('path' => 'example/' . $node->field1, $breadcrumb[] = array('path' => 'example/' . $node->field1,

View File

@ -1325,6 +1325,17 @@ function node_show($node, $message = FALSE) {
return node_view_multiple(array($node->nid => $node), 'full'); return node_view_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 * Process variables for node.tpl.php
* *
@ -1350,7 +1361,7 @@ function template_preprocess_node(&$variables) {
$variables['name'] = theme('username', array('account' => $node)); $variables['name'] = theme('username', array('account' => $node));
$variables['node_url'] = url('node/' . $node->nid); $variables['node_url'] = url('node/' . $node->nid);
$variables['node_title'] = check_plain($node->title[LANGUAGE_NONE][0]['value']); $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)) { if (!empty($node->in_preview)) {
unset($node->content['links']); unset($node->content['links']);