Same content, different nodes, different layouts

Author Message

Nabil Alimi

Tuesday 08 November 2005 9:37:44 am

Hi,

Is it possible to set different override methods for a same node ?

I mean.

I have several articles. They are stored in a "articles folder" let's say node 7.

I have 2 pages :
- layout one
- layout two

To display articles on them, i fetches my article folder

fetch(content,list,hash(parent_node_id,7...))

And i display them using

 {node_view_gui content_node=$my_article view=line}

So this is the same template for the both pages.
But I have 2 <b>line_view_article.tpl</b>.
line_view_article_1.tpl for layout 1
line_view_article_2.tpl for layout 2

I thought it could be possible to specify that each line_view templates will be used for one specified node using the <b>Match[node]=...</b> but this refers to the node of the content that is called through the node_view_gui.
And I wanted it to refer to the node_id I am currently on.

Is it possible ?

(Wow pretty long post)

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Alexandre Abric

Wednesday 09 November 2005 12:52:25 am

What you did should work ... Is this a bug ?

Try creating the rule with the admin interface, and then edit it.

Gurudutt Verma

Wednesday 09 November 2005 1:28:00 am

Hi!

What is the criteria to distinguish node, I mean How will you decide when the node should use line_view_article_1.tpl or line_view_article_2.tpl

One temprerory solution of this is:
on the basis of your criteria try to use view=line and view=full or else and try to override these two templates.

Nabil Alimi

Wednesday 09 November 2005 2:03:21 am

Hi,

I wanted to use the Match[node] condition.

In my override.ini.append.php file it looked like this :

[line_article_1]
Source=node/view/line.tpl
Subdir=templates
MatchFile=test/line_article_1.tpl
Match[node]=60

[line_article_2]
Source=node/view/line.tpl
Subdir=templates
MatchFile=test/line_article_2.tpl
Match[node]=61

But the <b>Match[node]</b> condition seems to refer to the node of the object you want to display using the template, not the node you are currently on. :-/
Maybe i can add a switch statement in an unique line_article.tpl file. Case the current node is 60, i'll include line_article_node_60.tpl, line_article_node_59.tpl etc... But that's not a very clean way.
Or maybe i missed something.

Thanks to both of you for your help.

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Gurudutt Verma

Wednesday 09 November 2005 2:26:27 am

Hi

if you have two different nodes and want to use two different template then your override.ini.append.php seems to be correct.

May be you are missing something else, but then this is the correct method of doing this. please reffer this for more help

http://ez.no/doc/ez_publish/technical_manual/3_6/templates/the_template_override_system/template_override_example

http://ez.no/doc/ez_publish/technical_manual/3_6/reference/template_override_conditions

http://ez.no/products/ez_publish_cms/documentation/customization/custom_design/override_templates

I hope these links will help you.

All the best :-)

Nabil Alimi

Wednesday 09 November 2005 2:41:02 am

Yes I have 2 different templates but in fact that's what my main template look like :

{def $all_articles=fetch(content,list,hash(parent_node_id,2,class_filter_type,'include',class_filter_array,array('article')))}
{foreach $all_articles as $un_article}
{node_view_gui view=line content_node=$un_article}
{/foreach}

And just for testing purpose, my 2 line_article_#.tpl :

This is your intro :<br />
{attribute_view_gui attribute=$node.object.data_map.intro}

And the 2nd one.

{attribute_view_gui attribute=$node.object.data_map.intro}
That was your intro

It's the node_view_gui that seems problematic...

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.