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))}

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 19 2025 07:02:42
Script start
Timing: Jan 19 2025 07:02:42
Module start 'layout'
Timing: Jan 19 2025 07:02:42
Module start 'content'
Timing: Jan 19 2025 07:02:43
Module end 'content'
Timing: Jan 19 2025 07:02:43
Script end

Main resources:

Total runtime1.2831 sec
Peak memory usage4,096.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 589.2813152.6406
Module start 'layout' 0.00690.0033 741.921939.4609
Module start 'content' 0.01021.2712 781.3828648.0625
Module end 'content' 1.28140.0017 1,429.445316.1406
Script end 1.2831  1,445.5859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.2615160.0002
Check MTime0.00140.1091160.0001
Mysql Total
Database connection0.00100.079310.0010
Mysqli_queries1.212894.5229700.0173
Looping result0.00100.0762680.0000
Template Total1.246197.120.6230
Template load0.00220.169020.0011
Template processing1.243996.942720.6219
Template load and register function0.00030.020510.0003
states
state_id_array0.00140.107310.0014
state_identifier_array0.00260.199820.0013
Override
Cache load0.00180.1400520.0000
Sytem overhead
Fetch class attribute can translate value0.00080.061340.0002
Fetch class attribute name0.00210.163880.0003
XML
Image XML parsing0.00140.111740.0004
class_abstraction
Instantiating content class attribute0.00000.001990.0000
General
dbfile0.00180.1440220.0001
String conversion0.00000.000540.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs