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.

eZ debug

Timing: Jan 18 2025 22:39:25
Script start
Timing: Jan 18 2025 22:39:25
Module start 'layout'
Timing: Jan 18 2025 22:39:25
Module start 'content'
Timing: Jan 18 2025 22:39:26
Module end 'content'
Timing: Jan 18 2025 22:39:26
Script end

Main resources:

Total runtime0.6728 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 589.0703152.6250
Module start 'layout' 0.00740.0038 741.695339.4453
Module start 'content' 0.01110.6602 781.1406595.9219
Module end 'content' 0.67140.0014 1,377.062512.1563
Script end 0.6728  1,389.2188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.5297160.0002
Check MTime0.00150.2236160.0001
Mysql Total
Database connection0.00120.183110.0012
Mysqli_queries0.611190.8284620.0099
Looping result0.00070.1012600.0000
Template Total0.640795.220.3204
Template load0.00240.356020.0012
Template processing0.638394.869320.3191
Template load and register function0.00010.014610.0001
states
state_id_array0.00090.126510.0009
state_identifier_array0.00070.100120.0003
Override
Cache load0.00200.2958320.0001
Sytem overhead
Fetch class attribute can translate value0.00080.119730.0003
Fetch class attribute name0.00120.176670.0002
XML
Image XML parsing0.00150.223430.0005
class_abstraction
Instantiating content class attribute0.00000.002180.0000
General
dbfile0.00110.1680280.0000
String conversion0.00000.001440.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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs