Forums / Setup & design / Fetching unique nodes with tree

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

eZ debug

Timing: Jan 18 2025 11:29:30
Script start
Timing: Jan 18 2025 11:29:30
Module start 'content'
Timing: Jan 18 2025 11:29:30
Module end 'content'
Timing: Jan 18 2025 11:29:30
Script end

Main resources:

Total runtime0.7559 sec
Peak memory usage4,096.0000 KB
Database Queries202

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0081 587.7266180.8359
Module start 'content' 0.00810.6467 768.5625528.7344
Module end 'content' 0.65480.1010 1,297.2969334.1328
Script end 0.7558  1,631.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00440.5774210.0002
Check MTime0.00150.1957210.0001
Mysql Total
Database connection0.00150.198210.0015
Mysqli_queries0.689491.20732020.0034
Looping result0.00150.20352000.0000
Template Total0.725896.020.3629
Template load0.00220.297520.0011
Template processing0.723695.726920.3618
Template load and register function0.00020.022510.0002
states
state_id_array0.00110.145510.0011
state_identifier_array0.00060.076620.0003
Override
Cache load0.00190.2455410.0000
Sytem overhead
Fetch class attribute can translate value0.00090.121540.0002
Fetch class attribute name0.00240.313650.0005
XML
Image XML parsing0.00050.064740.0001
class_abstraction
Instantiating content class attribute0.00000.001250.0000
General
dbfile0.00180.2439210.0001
String conversion0.00000.001030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs