Show latest news on homepage

Author Message

Juan Camilo

Saturday 22 April 2006 6:18:58 am

Hello everybody

I'm working on a new site with eZ and I need to show a little block on the home page listing the latest published news. By default there's a block with news but it is not appearing in my index, the pagelayout.tpl I'm using is practically the same as the default. Why could be the reason the news are not displayed?

André R.

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

Juan Camilo

Saturday 22 April 2006 8:52:37 am

Ok. Thanks a lot.

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 31 2025 04:17:08
Script start
Timing: Jan 31 2025 04:17:08
Module start 'layout'
Timing: Jan 31 2025 04:17:08
Module start 'content'
Timing: Jan 31 2025 04:17:08
Module end 'content'
Timing: Jan 31 2025 04:17:08
Script end

Main resources:

Total runtime0.0159 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 588.1328151.2109
Module start 'layout' 0.00470.0029 739.343836.6484
Module start 'content' 0.00760.0066 775.992290.2656
Module end 'content' 0.01430.0016 866.257833.9922
Script end 0.0159  900.2500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002515.7086140.0002
Check MTime0.00116.8779140.0001
Mysql Total
Database connection0.00074.529310.0007
Mysqli_queries0.002515.876530.0008
Looping result0.00000.075010.0000
Template Total0.00127.910.0012
Template load0.00095.642110.0009
Template processing0.00032.177710.0003
Override
Cache load0.00064.031410.0006
General
dbfile0.001911.756780.0002
String conversion0.00000.031540.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs