Forums / Setup & design / Multiple templates for new article.

Multiple templates for new article.

Author Message

Endre Solem

Friday 25 August 2006 1:50:05 am

Hello.

I guess this question must have been answered before, but I couldn't find it in the forum.

I have a site woth lots of new. We have organised it so the first 5 news articles is displayed on the frontpage, and the reste for this month in the archive.

I need a web do override the template for the article/class then its shown in the archive... is there a way to do this?

Thanks

Endre

Claudia Kosny

Thursday 31 August 2006 10:22:19 am

Hello Endre

In case you are still looking for an answer: There are several ways to achieve that depending on how you call up the articles. If I understand you right, you need two templates for the article class, one for the archived version and one for the frontpage.

On the frontpage you most likely do a fetch to get the 5 latest articles and go though the fetched nodes and display each one. A way to display them is to call up the
{node_view_gui ..} function where you can specify the template that will be used for displaying the node.
Here an example (copied from the documentation at http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_functions/visualization/node_view_gui )

 {def $my_node=fetch( 'content', 'node', hash( 'node_id', 96 ) )}
 {node_view_gui view='example' content_node=$my_node}

In this example, node number 96 is fetched and stored in $my_node. The "node_view_gui" function is used to display the target node using the "example" view. If there are no override rules for the specified view, the system will search for "example.tpl" in the "templates/node/view/" directory of the current design. If the requested template file is not found, eZ publish will continue searching for it in the fallback designs and the standard design. 

If the archived nodes are called up using their url (something like archive/name_of_node) they are displayed using the templates/full/article.tpl template. Just override this template by creating your own template file and put it into the folder <your design folder>/override/templates/full/article.tpl.

If the archived nodes are not called up using their url you have to fetch them somehow. In this case you can use the view parameter of the node_view_gui function again, just provide a different template.

If this does not answer your question please provide more information about the structure of your site - where and how the nodes are displayed and where they are stored.

Greetings from Luxembourg

Claudia