Forums / General / Fetching all nodes of a particular class

Fetching all nodes of a particular class

Author Message

Ben Pirt

Monday 05 January 2004 6:50:27 am

Hello all,
I have set up a blog site and am looking to be able to display the most recent comments on blog entries for the site in a sidebar.
The site structure is as foollows;

blogs
---- blog number 1
---- ---- Comment 1
---- ---- Comment 2
---- blog number 2
---- ---- Comment 3

etc.

I would like to be able to select the most recent comments from this structure, but it seems like I have to specify a parent node_id in the fetch statement, which rules out this possibility as the comments could be under a large number of blog nodes.

Is there any way of achieving this?

All help much appreciated.

Ben Pirt

Marco Zinn

Monday 05 January 2004 5:02:12 pm

Ben,
yes you can do this with a "tree" fetch.
I don't the syntax ready, but search the documentation for "fetch" and maybe "tree".
It works like: provide a root node ID (ID of blogs) and one (or more?) classes and you will get an array of nodes.
Usually, this is done to show the last modified (or published) article.

Marco
http://www.hyperroad-design.com

Balazs Halasy

Tuesday 06 January 2004 3:54:43 am

I think you would need to do something like this:
(just typed it in, haven't tested it..)

{let stuff=fetch('content', 'tree', hash('parent_node_id',2,
'class_filter_type', 'include',
'class_filter_array', array('comment'),
'sort_by', 'published',
'limit', 10))}

{* $stuff now includes the 10 most recent comments... *}

{/let}

Balazs

Ben Pirt

Tuesday 06 January 2004 4:30:44 am

Thanks for your help, worked a treat :-)
Ben Pirt

Marco Zinn

Tuesday 06 January 2004 1:06:08 pm

Balacs, as I see you active in the forums:
Please try to evaluate, which questions in the forums are "frequent" and try to transfer them into the documentation area.
I think, this (fetch tree) is some common template issue. It just need the right question ("how do I get all objects of a class from my site?") and one or two sample in "fetch" documentation.
Good work at the tutorial, btw (I just miss documentation on the existing workflows steps...).

Marco
http://www.hyperroad-design.com

Sam Wong

Tuesday 06 January 2004 7:51:09 pm

I was wondering which documentation contains syntax explanation for all the ez3-exclusive commands, like this fetch. I don't understand what this line is about.

{let stuff=fetch('content', 'tree', hash('parent_node_id',2,
'class_filter_type', 'include',
'class_filter_array', array('comment'),
'sort_by', 'published',
'limit', 10))}

eZ debug

Timing: Jan 19 2025 04:21:00
Script start
Timing: Jan 19 2025 04:21:00
Module start 'content'
Timing: Jan 19 2025 04:21:00
Module end 'content'
Timing: Jan 19 2025 04:21:00
Script end

Main resources:

Total runtime0.1646 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 590.1953180.8203
Module start 'content' 0.00650.0066 771.015697.8828
Module end 'content' 0.01300.1515 868.8984527.1250
Script end 0.1646  1,396.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00342.0692200.0002
Check MTime0.00130.7896200.0001
Mysql Total
Database connection0.00060.390010.0006
Mysqli_queries0.122374.28331410.0009
Looping result0.00120.75471390.0000
Template Total0.151291.810.1512
Template load0.00070.420410.0007
Template processing0.150591.407010.1505
Override
Cache load0.00040.272710.0004
Sytem overhead
Fetch class attribute can translate value0.00070.432510.0007
XML
Image XML parsing0.00030.191310.0003
General
dbfile0.00261.5592200.0001
String conversion0.00000.004830.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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