Saturday 22 April 2006 7:51:08 am
eZ3.6++ sample code for looping thru the 5 last modified articles in a override template. Search for sort_by in ec.no/doc to see how to get the 5 last Published articles.
<div class="content-view-children">
{def $list_items=fetch( 'content','list', hash(
'parent_node_id', 130,
'offset', 0,
'class_filter_type', 'include',
'class_filter_array', array('article'),
'sort_by', array( 'modified', false()),
'limit', 5 ) )
}
<h2>Last news:</h2>
{foreach $list_items as $item}
<div class="content-view-line">
<div class="class-article">
<h3><a href={$item.url_alias|ezurl}>{$item.object.data_map.title.content|wash}</a></h3>
{section show=$item.object.data_map.intro.content.is_empty|not}
<div class="attribute-short">
{attribute_view_gui attribute=$item.object.data_map.intro}
</div>
{/section}
</div>
</div>
{/foreach}
{undef $list_items}
</div>
use the 'tree' fetch function to include articles in sub nodes as well. http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions
to have a list of latest news in the pagelayout, it would probalby be a good idea to remove attribute-short or having less nr of articles fetched.
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom
|