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
Comment #1
ronan commentedThanks for doing the research on this. I'll look into it as soon as I get a chance.
Comment #2
darrylind commentedI 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
Comment #3
darrylind commentedWell, 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.
Comment #4
darrylind commentedPlease see previous comments.
Comment #5
ajevans85 commentedI have this problem.
The offending code is on the implementation of hook_nodeapi()
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.
Comment #6
ajevans85 commentedForget my last post, I'm completely wrong.
Below is the offending function causing the issues
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.
Comment #7
robynover commentedI also have this problem. The fix in #6 worked for me.
Comment #8
markhalliwellCopy & 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.