Not sure if this is a cause of Path Auto or Node Hierarchy, or both. I use the phptemplate_preprocess_page hook in my template file to setup page specific templates for specific nodes. However 'nodes' which have a parent do not seem to get the correct $vars loaded, it is always the first parent whose information is loaded into the vars.

Parent ($vars[node]->nid = 2)
- Child ($vars[node]->nid = 2)
- Child ($vars[node]->nid = 2)
- More Childs ($vars[node]->nid = 2)

The code below I use to view what the vars are on each page. I

/**
 * Override or insert PHPTemplate variables into the templates.
 */
function phptemplate_preprocess_page(&$vars) {
    //code block from the Drupal handbook
         
  // $vars['node'] is available when the page is focused on a node. i.e., example.com/node/123
  if (isset($vars['node'])) {
    // Add template naming suggestion. It should alway use hyphens.
    // If node type is "custom_news", it will pickup "page-custom-news.tpl.php".
    $vars['template_files'][] = 'page-'. str_replace('_', '-', $vars['node']->type);
  }
  
  echo("<pre>");
  print_r($vars);
  echo("</pre>");
}

Comments

ronan’s picture

Thanks for doing the research on this. I'll look into it as soon as I get a chance.

darrylind’s picture

Version: 6.x-1.0 » 6.x-1.2

I believe that I have a problem that is related to the same issue. I have child nodes (custom content type: article) that when are displayed as node pages of their own will display the $body_classes of the parent (custom content type: section). So the node pages for the articles list node-type-section in the tag html. Also the article nodes have a node ID of its parent. I would like to control CSS and block visibility by node type, but the node type is that of its parent. Also taxonomy information does not seem to be passed to the node view.

I'm not sure if I'm having this issue because of module conflicts, but I have tried to turn off other similar modules. I am using Zen theme.

Thanks,
Darryl

darrylind’s picture

Status: Active » Closed (fixed)

Well, things appear to be working correctly now. I think a caching issue may have caused the problem. Not sure what sort of caching, since I cleared caches before reporting.

Thanks for the great module!

I'm not sure if this closes the previous reply, so please review the previous entry.

darrylind’s picture

Status: Closed (fixed) » Active

Please see previous comments.

ajevans85’s picture

I have this problem.

The offending code is on the implementation of hook_nodeapi()

<?php

/**
 * Implmentation of hook_nodeapi().
 */
function nodehierarchy_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
    case 'fields':
    return;
    case 'insert':
    case 'update':
      nodehierarchy_invoke_api("update_parent", $node);
      break;
    case 'load':
      return array('parent' =>nodehierarchy_load_node($node));
    break;
    case 'delete':
      nodehierarchy_delete_node($node);
      break;
    case 'validate':
      break;
    case 'view':
      if ($page && !$teaser) {
        nodehierarchy_set_breadcrumbs($node);
      }
      break;
  }
}

?>

On hook load the current node to be displayed is completely overwritten with it's parent. I guess all we really need to know is if the node has a parent, we don't have to actually fully load the parent details up so I have updated the function to the below, note this hasn't been tested yet but i'll update if I find any issues.

<?php

/**
 * Implmentation of hook_nodeapi().
 */
function nodehierarchy_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
    case 'fields':
    return;
    case 'insert':
    case 'update':
      nodehierarchy_invoke_api("update_parent", $node);
      break;
    case 'load':
      $parent = nodehierarchy_load_node($node);
      return array('parent_nid' => $parent['nid']);      
    break;
    case 'delete':
      nodehierarchy_delete_node($node);
      break;
    case 'validate':
      break;
    case 'view':
      if ($page && !$teaser) {
        nodehierarchy_set_breadcrumbs($node);
      }
      break;
  }
}

?>
ajevans85’s picture

Forget my last post, I'm completely wrong.

Below is the offending function causing the issues

<?php
function nodehierarchy_set_breadcrumbs($node, $add_node = FALSE) {
   
  // Place the given node.
  $breadcrumb = array();

  $parent     = $node;
  $homepage   = drupal_get_normal_path(variable_get('site_frontpage', 'node'));
  // If any of the node's decendents have a menu, set it to current.
  $router_item = null;

  
  while (@$parent->nid) {
     
    $item = menu_get_item("node/". $parent->nid);
    
    if (!$router_item && _nodehierarchy_get_menu($parent->nid)) {
      $router_item = $item;
    }
    if (($add_node || $parent->nid != $node->nid) && $item['href'] != '<front>' && $item['href'] != $homepage) {
      $breadcrumb[] = l($parent->title, "node/". $parent->nid);
    }
    $parent = node_load($parent->parent);
  }
  $breadcrumb[] = l(t('Home'), '<front>');

  if ($router_item) {
    menu_set_item($_GET['q'], $router_item);
  }
  drupal_set_breadcrumb(array_reverse($breadcrumb));
}
?>

The problem line is the menu_set_item($_GET['q'], $router_item); . No fix as of yet as on limited time to get a site up but commenting it out is a tempoary solution for me.

robynover’s picture

I also have this problem. The fix in #6 worked for me.

markhalliwell’s picture

Component: Code » Drupal/PHP Code

Copy & Pasted: This issue pertains to the 6.x-1.x branch which is now legacy and is over one year old. If this issue is not applicable anymore, please consider closing it. Otherwise, please update this issue appropriately. Will be closed in two weeks if no response.