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.