Why this code does not work?

Author Message

Daniele Nocentini

Tuesday 15 March 2005 8:56:44 am

I want to display the node name of a specific node, my code is this:

{switch name=Sw1 match=$node.object.section_id}
{case match=6}
{let children=fetch(content,node,hash(node_id,98))}{$children.data_map.name.content|upcase}{/let}
{/case}
{/switch}

I can enter inside the case of the swith but don't show me the node name.

Antica Bottega Digitale srl
http://www.abd.it

Łukasz Serwatka

Tuesday 15 March 2005 9:21:26 am

{switch name=Sw1 match=$node.object.section_id}
    {case match=6}
        {let children=fetch(content,node,hash(node_id,98))}
            {$Sw1:children.data_map.name.content|upcase}
         {/let}
    {/case}
{/switch}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Hans Melis

Tuesday 15 March 2005 9:26:36 am

With the <i>name</i> attribute in the switch-tag, you open a new namespace. All variables declared inside the namespace must be referenced with the namespace as part of the variable name. The general form is {$namespace:myvariable}, where <i>namespace</i> can consist of several nested namespaces. To reference the current (active) namespace, you can also use {$:myvariable}. (More info: http://ez.no/ez_publish/documentation/development/libraries/ez_template/basics/namespaces)

In your case, it would be: {$Sw1:children.data_map.name.content} or {$:children.data_map.name.content}.

But I would suggest to get rid of the <i>name</i> parameter. It's not needed and makes things more complicated than they should be.

hth

Edit: Lukasz didn't elaborate as much and beat me to it...

Hans
http://blog.hansmelis.be

Łukasz Serwatka

Tuesday 15 March 2005 9:45:30 am

Yep, I agree with Hans, this was to fast...

Daniele, more about Namespaces with code example you can find here.
http://ez.no/ez_publish/documentation/development/libraries/ez_template/basics/namespaces

But Hans wrote summary as well ;-)

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Daniele Nocentini

Wednesday 16 March 2005 12:00:58 am

Yes now it work fine, thank you very much!

Antica Bottega Digitale srl
http://www.abd.it

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