Why dont this code work?

Author Message

Claus Jensen

Thursday 28 August 2003 4:19:53 am

Hi,
I try to fetch the child objects of the childs of Frontpage (node id = 2), so i can make a menu with subitems of items and so on. And then I get this from debug:
Unknown template variable 'children2' in namespace ''

Here's the code:
{let children=fetch('content',list,hash(parent_node_id,2))}
{section name=Child loop=$children}

<table border="0">
<tr>
<td><p><font color="#FF6600"><strong>{$Child:item.name|wash}</strong></font></p></td>
</tr>
{let children2=fetch('content',list,hash(parent_node_id,$Child:item.node_id))}
{section name=Child2 loop=$children2}

<tr>
<td><p><strong>{$Child2:item.name|wash} </strong></p>
</td>
</tr>
{/section}
{/let}
<tr>
<td>
<table width="100%" border="0" cellpadding="1" cellspacing="1">
<tr>
<td rowspan="5"></td>
<td></td>
</tr>
</table>
</td>
</tr>
</table>

{/section}
{/let}

thanks,
claÜs

Jan Borsodi

Thursday 28 August 2003 4:39:33 am

You are changing the namespace here:
{section name=Child loop=$children}

This means that you have to refer to the variable in that namespace like this:

{let children2=fetch('content',list,hash(parent_node_id,$Child:item.node_id))}
{section name=Child2 loop=$Child:children2}

Also the next variable lookup must have the first namespace as well, like:
{$Child:Child2:item.name|wash}

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Claus Jensen

Thursday 28 August 2003 4:57:47 am

AHA! Its ez!

Thanks Jan,
claÜs

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