Display most recent articles

Author Message

Steph A

Tuesday 01 March 2005 3:31:05 am

NEWBIE QUESTION

I am using the code below now. But then I get ALL of the articles in the subfolders. How can I sort this so that only the 3 most recent articles show?

The output now shows the recent articles at the bottom - and I want it on the top....

{* Fetch all subfolders, each representing a news category *}
{let subfolders=fetch( content,
	list,
		hash( 'parent_node_id', 2,
		class_filter_type, include,
                                depth,3,
		class_filter_array, array( 'folder' )
		)
	)
} 





{* For each subfolder, fetch the articles *}
{section loop=$subfolders}
{let articles=fetch( content,
	list,
		hash( 'parent_node_id', $:item.node_id,
		class_filter_type, include,
		class_filter_array, array( 'article' )
		)
	)
}
	{* For each article, display the name and the url to the article and the category *}
	{section loop=$articles}
	{* Use line view to show articles *}
                {node_view_gui view=line content_node=$:item}
	{/section}
	{/let}

{/section}

{/let}

Anybody?

Łukasz Serwatka

Tuesday 01 March 2005 3:56:31 am

Hi Steph,

Here you can read more about data fetching (including examples).
http://ez.no/ez_publish/documentation/reference/data_fetching/content/list

Use sort_by and limit attributes.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Steph A

Tuesday 01 March 2005 5:30:31 am

Okay, I tried to use the "sort_by" parameter - but I cant make it work.

What am I doing wrong?

{* Fetch all subfolders, each representing a news category *}
{let subfolders=fetch( content,
	list,
		hash( 'parent_node_id', 2,
		class_filter_type, include,
                                depth,3,
		class_filter_array, array( 'folder' )
		)
	)
} 





{* For each subfolder, fetch the articles *}
{section loop=$subfolders}
{let articles=fetch( content,
	list,
		hash( 'parent_node_id', $:item.node_id,
                sort_by, array( array( published, false() ),   <------ wrong???
		class_filter_type, include,
		class_filter_array, array( 'article' )
		)
	)
}
	{* For each article, display the name and the url to the article and the category *}
	{section loop=$articles}
	{* Use line view to show articles *}
                {node_view_gui view=line content_node=$:item}
	{/section}
	{/let}

{/section}

{/let}

luis muñoz

Tuesday 01 March 2005 5:52:22 am

try this:
Order by priority in the admin and fetch like this in the code

{let news_list=fetch('content','list', hash( parent_node_id, $auxlangnode.node_id,									   limit, 20,									   sort_by, array( priority, true() ),						   class_filter_type, include,						  class_filter_array, array( 'guide_article' ) ))}
										{section name=newsitem loop=$news_list}

Roy Bøhmer

Tuesday 01 March 2005 7:55:42 am

Just a typo i guess...

 sort_by, array( array( published, false() )),

You forgot a

)

roy

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 01:24:02
Script start
Timing: Jan 19 2025 01:24:02
Module start 'layout'
Timing: Jan 19 2025 01:24:02
Module start 'content'
Timing: Jan 19 2025 01:24:03
Module end 'content'
Timing: Jan 19 2025 01:24:03
Script end

Main resources:

Total runtime0.7475 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 589.1484152.6250
Module start 'layout' 0.00510.0032 741.773439.4453
Module start 'content' 0.00830.7370 781.2188632.5000
Module end 'content' 0.74530.0022 1,413.718812.1641
Script end 0.7475  1,425.8828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4140160.0002
Check MTime0.00130.1771160.0001
Mysql Total
Database connection0.00070.096810.0007
Mysqli_queries0.692392.6147670.0103
Looping result0.00080.1018650.0000
Template Total0.717195.920.3585
Template load0.00220.293620.0011
Template processing0.714895.626020.3574
Template load and register function0.00010.016710.0001
states
state_id_array0.00090.125110.0009
state_identifier_array0.00120.154520.0006
Override
Cache load0.00190.2480280.0001
Sytem overhead
Fetch class attribute can translate value0.00060.073640.0001
Fetch class attribute name0.00140.193760.0002
XML
Image XML parsing0.00090.123240.0002
class_abstraction
Instantiating content class attribute0.00000.001660.0000
General
dbfile0.00080.1102180.0000
String conversion0.00000.001140.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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/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: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs