Fetching unique nodes with tree

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:28:08
Script start
Timing: Jan 18 2025 16:28:08
Module start 'layout'
Timing: Jan 18 2025 16:28:08
Module start 'content'
Timing: Jan 18 2025 16:28:08
Module end 'content'
Timing: Jan 18 2025 16:28:08
Script end

Main resources:

Total runtime0.0182 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0084 589.3438152.6250
Module start 'layout' 0.00840.0032 741.968839.4609
Module start 'content' 0.01160.0046 781.429789.2109
Module end 'content' 0.01630.0019 870.640634.3047
Script end 0.0182  904.9453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002915.7792140.0002
Check MTime0.00116.1514140.0001
Mysql Total
Database connection0.00137.392110.0013
Mysqli_queries0.002916.047230.0010
Looping result0.00000.070610.0000
Template Total0.00168.610.0016
Template load0.00094.666210.0009
Template processing0.00073.883010.0007
Override
Cache load0.00063.081610.0006
General
dbfile0.00021.327080.0000
String conversion0.00000.043140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs