Find child nodes for node nid

illSleepWheniDie - August 6, 2009 - 09:56
Project:Node Relativity
Version:6.x-3.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

Bug Report with solution:

MY TASK
Using Views, find all child nids for a parent nid.

WHAT I DID
Created a view with these parameters

  • Relationships
    • -none-
  • Arguments
    • Node: nid
  • Fields
    • Node: nid
    • Node Relativity: Child Node ID
  • Sort
    • -none-
  • Filter
    • -none-

PROBLEM
The query generated by views

SELECT node.nid AS nid,
   relativity.nid AS relativity_nid
FROM node node
LEFT JOIN relativity relativity ON node.nid = relativity.nid
WHERE node.nid = 12

is wrong.

"node.nid = relativity.nid" should be "node.nid = relativity.parent_nid"

SOLUTION
Change relativity.views.inc line 22

from
'field' => 'nid',
to
'field' => 'parent_nid',

That's it. I'm sorry but I don't know how to make a proper patch. If a patch is needed, it'd be great if someone makes it and puts it up.

Cheers
Alex Arul

 
 

Drupal is a registered trademark of Dries Buytaert.