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.