menu_get_object returns wrong node on children nodes

andreiashu - May 13, 2009 - 15:03
Project:Node Hierarchy
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi,

I have two nodes created: one parent (nid: 1) and another one node (nid: 2) that is a child of the first node.

When going to node/1 menu_get_object returns the correct node (nid:1) but on node/2 it returns the parent node (nid: 1) instead of the current one.

Does anyone know if how to fix this ?
Thanks

#1

andreiashu - May 13, 2009 - 15:55

The same thing happens with menu_get_active_title: when you call it on a child node page it returns the parent's title.
Can anyone else confirm/unconfirm this one ?

#2

andreiashu - May 15, 2009 - 09:45

The problem is with nodehierarchy_set_breadcrumbs function, more specifically with the call to menu_set_item in this function (line 789).

Here is the part of code that I'm talking about:

  if ($router_item) {
    menu_set_item($_GET['q'], $router_item);
  }

If I comment the menu_set_item line everything works as expected (as far as I can tell).
Any thoughts about this ?

#3

ronan - May 27, 2009 - 02:25
Status:active» fixed

Yep, this is an issue with some sloppy porting from 5.x to 6.x. I'm working on a 2.x branch which uses the 6.x menu system in a much, much better way (instead of fighting it like the current version does). But for now, just commenting out that line takes care of the issue.

I've removed this code from the latest dev (I had actually implemented this workaround a while ago and forgot to commit the change, sorry about that).

Thanks
Ronan

#4

System Message - June 10, 2009 - 02:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.