[SOLVED] Display only 1 latest news post on home page?

Author Message

Nathan Kelly

Saturday 10 September 2005 12:41:37 am

Hi all, I'm setting up my home page as per: http://ez.no/community/forum/setup_design/object_relation_question

Basically I need to fetch the most recently published news article from the news section so I have done the following (This is the only way I have found that looks like what I need).

{def $recent_news=fetch('content', 'list',
			hash('parent_node_id', 70,
		    		'limit', 1,
				'class_filter_type', include,
				'class_filter_array', array('article'),
				'sort_by', array('published', false() ) ) )}

...Not sure what to put here...

{undef}

But I keep getting errors with the output, the article wont show up?

I have tried all sorts of variations of the node_view_gui method, can anyone suggest either a better way to do this, or an alternative to node_view_gui?

Cheers!

Pardon me while I burst into flames...

Gabriel Ambuehl

Saturday 10 September 2005 12:47:03 am

What does a
{$recent_news | attribute(show)}

yield.

Visit http://triligon.org

Kristof Coomans

Saturday 10 September 2005 4:56:29 am

{if $recent_news|count|gt(0)}
    {node_view_gui view='line' content_node=$recent_news.0}
{/if}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Nathan Kelly

Sunday 11 September 2005 4:14:21 pm

Thankyou once again Kristof recent news article is now showing up perfectly.

Cheers!!

Pardon me while I burst into flames...

Nathan Kelly

Sunday 11 September 2005 8:32:12 pm

Ahh, that said I now face another problem...

In my news section (section 7, node 70) I have my articles displaying in a shortened format with image, title, date, shortened intro and read more link. This uses the article.tpl located in: mydesign/override/templates/line/article.tpl

On my home page (section 6, node 2) I would like to omit the image and date whilst adding a "Recent News" header, so I have made a new home_article.tpl and placed it in: mydesign/override/templates/line/home_article.tpl

I have set my overrides as follows: -

[home_article_line]
Source=line/article.tpl
MatchFile=line/home_article.tpl
Subdir=templates
Match[class_identifier]=article
Match[section]=6

[article_line]
Source=node/view/line.tpl
MatchFile=line/article.tpl
Subdir=templates
Match[class_identifier]=article

But my article_line override is still taking precedence over my home_article_line.

What I have tried and failed:
1. Using node/view/line.tpl as Source template
2. Adding Match[node]=2
3. Matching [article_line] to section 7
3. Changing the directory of my home_article.tpl
4. Changing the order of the overrides within override.ini.append.php
5. And many more variations + clearing cache constantly.

Debug output shows no errors, I also have "list of used templates" enabled, it shows that the requested .tpl is line/article.tpl and the used template is the same. However with some configurations it shows that no template is requested or used, though the rendered output would suggest it is in-fact using the line/article.tpl

Is it possible to override an existing override or am I simply barking up the wrong tree?

Can anyone suggest what may be the problem and how I may overcome it?

I havn't had any trouble with overrides until now; all of my other overrides have worked as expected.

Cheers!

Pardon me while I burst into flames...

Nathan Kelly

Sunday 11 September 2005 10:29:05 pm

[SOLVED]

It seems that there is no way to override the existing article override so I found a new solution that seems to do the trick.

In my home page template I have changed the reference to the view template to use: -

From - {node_view_gui view='line' content_node=$recent_news.0}

To - {node_view_gui view='home_article' content_node=$recent_news.0}

And then placed my home_article.tpl in: mydesign/override/templates/node/view/home_article.tpl

This means I dont need to set and override in override.ini.append.php, in this case I think this is a suitable solution.

Cheers!

Pardon me while I burst into flames...

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 08:56:43
Script start
Timing: Jan 19 2025 08:56:43
Module start 'layout'
Timing: Jan 19 2025 08:56:43
Module start 'content'
Timing: Jan 19 2025 08:56:44
Module end 'content'
Timing: Jan 19 2025 08:56:44
Script end

Main resources:

Total runtime1.0517 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.3984152.6563
Module start 'layout' 0.00640.0030 742.054739.4922
Module start 'content' 0.00951.0408 781.5469620.3516
Module end 'content' 1.05030.0013 1,401.898416.1250
Script end 1.0516  1,418.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3270160.0002
Check MTime0.00130.1239160.0001
Mysql Total
Database connection0.00080.072210.0008
Mysqli_queries0.974692.6675680.0143
Looping result0.00080.0732660.0000
Template Total1.008995.920.5045
Template load0.00220.205320.0011
Template processing1.006895.729220.5034
Template load and register function0.00020.020710.0002
states
state_id_array0.00140.133310.0014
state_identifier_array0.00170.164120.0009
Override
Cache load0.00190.1813500.0000
Sytem overhead
Fetch class attribute can translate value0.00090.085430.0003
Fetch class attribute name0.00120.116780.0002
XML
Image XML parsing0.00390.368530.0013
class_abstraction
Instantiating content class attribute0.00000.0020110.0000
General
dbfile0.00540.5122220.0002
String conversion0.00000.001040.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/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/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
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.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: 28
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs