[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.