Forums / General / switch case with the node ID.

switch case with the node ID.

Author Message

Christine Romel

Wednesday 29 September 2004 1:37:46 am

Hii eveybody..

would u plzz check what's the prob. on that code??
sorry..but i'm new to EZ publish and need ur help..

what i need to do is:
check for the selected node..
get its ID..
make a switch case on that ID..
if ID matches case1: set variable1 = value1 & set var2=val2....etc..
and then when the folder is shosen to be shown..take its variables var1 & var2 which are $left & $right (nodes IDs) and show their content..

the prob.
when i choose any node nothing appears...
NB: the prob. is not in the showing way itself(the bla bla bla part in the above code)...

help..plzz
=============================================================

is the nodeChosen variable contains the whole node object?

{let nodeChosen = fetch(content, node, hash(node_id,$cn)) right=0 left=0 km=222 hy=227}

/*is there something called $node.id coz i wanna check the node by its ID*/

{switch name=ShowArticle match=$node.id}
{case match=222}
{set right = 1124}
{set left = 1125}
{/case}

{case match=227}
{set right = 1132}
{set left = 1133}
{/case}

{/switch}
{/let}


<!--************ That's the first (right)column************************-->

<td valign="top" width="250px">
{let col=fetch(content,tree, hash(parent_node_id,$right,limit,4, sort_by,array(priority, true())))}


bla bla blaaa...



<!--************ That's the second (left )column**********************************-->

<td valign="top" width="250px">
{let col=fetch(content,tree, hash(parent_node_id, $left,limit,4, sort_by,array(priority, true())))}


bla bla bla...

--------------------
i need it urgently..
i really appreciate ur help..

christine..

Frederik Holljen

Wednesday 29 September 2004 1:41:40 am

Try $node.node_id

To see all the variables of $node use: {$node|attribute(show)}.
It might be handy to print this list for future reference..

Christine Romel

Wednesday 29 September 2004 4:11:37 am

Hii Fredrek

well..i was able to get the node ID..
but still there's a problem:((
i made global var. called right & left and assigned them a value as initialization..
but when i change their values in the switch case..they are not shown..

{switch name=ShowArticle match=$:nodeChosen.node_id}
{case match=222}
{section}{set $right=1124}{/section}
{section}{set $left=1125}{/section}
{/case}
{/switch}

and then their values here..are taken by the global ones not the newly changed ones:((

{let col=fetch(content,tree, hash(parent_node_id,$right,limit,4, sort_by,array(priority, true())))}

================================
sorry for disturbtion..
thanx for ur help a lott..

christine

Frederik Holljen

Wednesday 29 September 2004 4:30:17 am

I think you are having a namespace problem. Remove the name= in the switch, and use $: to address the left and right variables.
You can also read the documentation page about namespaces http://ez.no/ez_publish/documentation/development/libraries/ez_template/basics/namespaces.

In other words, something like:

<{switch match=$:nodeChosen.node_id}
 {case match=222}
 {section}{set $:right=1124}{/section}
 {section}{set $:left=1125}{/section}
 {/case}
 {/switch}

Of course, this will only work if you do not open a new namespace in the let (using name=) defining the left and right variables.

Christine Romel

Wednesday 29 September 2004 6:06:21 am

ok..i solved the namespace prob..:D
but..do u know how would i call a variable using namespaces inside the new name space itself..!

4ex.this code..
{let nodeChosen=fetch(content,node,hash(node_id,$cn)) name='let'}
{switch name='chosen' match=$:nodeChosen.node_id }
{case match=222}
{let right=1124 left=1125 name='case'}{/let}
{/case}
...
{let col=fetch(content,tree, hash(..,***** need to put the $chosen:case:right*****variable here,),...)}
.
.
.
{/let}
{/switch}
{/let}
i wrote it as mentioned but didn't work!!

 

Frederik Holljen

Wednesday 29 September 2004 7:24:07 am

You open three namespaces here 'let', 'chosen' and 'case.
Therefore:


 {let col=fetch(content,tree, hash(..,***** need to put the $let:chosen:case:right*****variable here,),...)}