Forums / Setup & design / Adding code in article.tp

Adding code in article.tp

Author Message

Pascal France

Saturday 06 May 2006 6:56:34 am

Hi,

I would like to add some code like that:

  1 {def
  2     $nodes1=fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id, 'sort_by', array(array('priority', true())) ) )
  3 }
  4 {def $node_count=fetch( 'content', 'list_count', hash( 'parent_node_id', $node.node_id ) )}
  5 {if gt($node_count,0)}
  6 The node has {$node_count} children.<br />
  7 {foreach $nodes1 as $node}
  8     <li>{$node.name|wash}</li>
  9             {def $child1=fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id ) )}
 10                 <ul>{foreach $child1 as $1child}
 11                     <li>{$1child.name|wash}</li>
 12                         {def $child2=fetch( 'content', 'list', hash( 'parent_node_id', $1child.node_id ) )}
 13                             <ul>{foreach $child2 as $2child}
 14                                 <li>{$2child.name|wash}</li>
 15                             {/foreach}</ul>
 16                 {/foreach}</ul>
 17 {/foreach}
 18 {/if}
 19 {undef $child1 $1child $child2 $2child}

to the top of design/plain/override/templates/full/article.tpl
But then, the rest of the template is not displayed: no more article name, intro and body are displayed.

If I add only:

  1 {def
  2     $nodes1=fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id, 'sort_by', array(array('priority', true())) ) )
  3 }
  4 {def $node_count=fetch( 'content', 'list_count', hash( 'parent_node_id', $node.node_id ) )}
  5 {if gt($node_count,0)}
  6 The node has {$node_count} children.<br />
  7 {/if}

...then all works fine.
I tried to remove {undef $child1 $1child $child2 $2child} or to put only {undef} without success.

Could someone tell me what is wrong ?

Regards

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Saturday 06 May 2006 8:15:40 am

Hi,

I found a dirty solution:

 1 {def
 2    $nodes1=fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id, 'sort_by', array(array('priority', true())) ) )
 3 $aaa=$node
 ""
 ""
 ""
 19 {undef}
 

...and then I replace all "$node" instances in the template by "$aaa"

But I think there is a clean solution.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Sunday 07 May 2006 3:17:26 am

Hi,

A more easy solution is:

 1 {def
 2   $nodes1=fetch( 'content', 'list', hash( 'parent_node_id', $node.node_id, 'sort_by', array(array('priority', true())) ) )
 3 $aaa=$node
 ""
 ""
 ""
 19 {undef}
 20 {def $node=$aaa}

Like that, I needn't to replace all $node instances.

But I really don't understand why I have to do that.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish