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.

eZ debug

Timing: Jan 20 2025 01:06:19
Script start
Timing: Jan 20 2025 01:06:19
Module start 'layout'
Timing: Jan 20 2025 01:06:19
Module start 'content'
Timing: Jan 20 2025 01:06:20
Module end 'content'
Timing: Jan 20 2025 01:06:20
Script end

Main resources:

Total runtime0.6733 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 589.1563152.6250
Module start 'layout' 0.00480.0024 741.781339.4453
Module start 'content' 0.00720.6644 781.2266607.5234
Module end 'content' 0.67160.0016 1,388.750016.1641
Script end 0.6733  1,404.9141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.5127160.0002
Check MTime0.00140.2121160.0001
Mysql Total
Database connection0.00070.100710.0007
Mysqli_queries0.608790.4001650.0094
Looping result0.00080.1192630.0000
Template Total0.643595.620.3217
Template load0.00220.326620.0011
Template processing0.641295.239120.3206
Template load and register function0.00010.021510.0001
states
state_id_array0.00130.191310.0013
state_identifier_array0.00120.181720.0006
Override
Cache load0.00190.2765260.0001
Sytem overhead
Fetch class attribute can translate value0.00120.181930.0004
Fetch class attribute name0.00130.192680.0002
XML
Image XML parsing0.00180.262630.0006
class_abstraction
Instantiating content class attribute0.00000.0031100.0000
General
dbfile0.00250.3648290.0001
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs