Author
|
Message
|
Roy Viggo Pedersen
|
Thursday 14 August 2003 1:44:38 am
Hi, How can I fetch unique nodes in a tree, like select distinct? I'm using a statement like this:
{let nodelist=fetch(content, tree, hash(
parent_node_id, 2,
class_filter_type, include,
class_filter_array, array( 2 ) )} If a article have several placements it shows up several times in nodelist. How can I avoid that?
Regards, Roy
|
Tristan Koen
|
Thursday 14 August 2003 3:06:55 am
Hi Roy, I haven't tested this, but perhaps the array operator unique() will work?
Try
{let nodelist=unique(fetch(content, tree, hash(
parent_node_id, 2,
class_filter_type, include,
class_filter_array, array( 2 ) ))}
|
Roy Viggo Pedersen
|
Thursday 14 August 2003 11:26:38 am
Hi, No, that wont work, as they are two different nodes ponting to the same contentobject. I checked in excontentobject_tree. I only want one node (the one with main placement) for each contentobject_id. Can this be done? Roy
|
Tristan Koen
|
Friday 15 August 2003 5:22:43 am
Hi Roy, Good point. I'm sure there is a better way to do this, but you could always take the brute-force approach.
1. Get a list of node_id's as you would normally.
2. Get the object_id for each of the node_id's and put it into an array. 3. Use the unique operator to filter out the duplicates. From there you should be able to loop through the array and display the items you want.
|
Mads Buus Jensen
|
Wednesday 27 August 2003 3:10:28 am
Just a thought: Usually your 'main nodes' and your 'other placement' have different depths in your tree, use the depth parameter on your fetch. Also if 'main node' are kept together, create a class for this 'main node container', and then start by fetching that container. Hope it helps (It did for me) -Mads
|