Last X Items of a Specific Class

Author Message

Alex Jones

Tuesday 02 September 2003 1:33:41 pm

How can I pull the most recently published items of a specific class from multiple folders some of which are themselves within folders?

For example,my site has a folder which contains a folder for each manufactuer we carry; I would like to fetch the five most recently added products (class 23) no matter who the manufacturer is.

Help would be greatly appreciated!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Hans Melis

Tuesday 02 September 2003 2:32:10 pm

Hi Alex,

I would try something like this:

{let most_recent=fetch('content', 'tree', hash(parent_node_id,<your_parent_node_id>, sort_by, array(published, false()), limit, 5, class_filter_type, include, class_filter_array, array(23)))}
.
.
.
{/let}

It's late here, so there might be the odd error in there ;) But I think it should work.

--
Hans

Hans
http://blog.hansmelis.be

Paul Borgermans

Wednesday 03 September 2003 5:12:24 am

Perhaps a clarification for fetch(content,tree... ) versus
fetch(content,list ....).

It al boils down to one little difference: the default value for the depth parameter. For content/list this is 1, meaning one level down where for content/tree it is 0, meaning unlimited depth.

So content/tree == content/list with depth=0

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Alex Jones

Wednesday 03 September 2003 6:14:31 am

Hans, thanks for the code snippet; I'll try that out today. It looks much cleaner than the nested fetches I was experimenting with.

Paul, thanks for the clarification regarding tree and list - I must admit I was unaware of that difference!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

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