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,),...)}

eZ debug

Timing: Jan 18 2025 21:01:22
Script start
Timing: Jan 18 2025 21:01:22
Module start 'content'
Timing: Jan 18 2025 21:01:22
Module end 'content'
Timing: Jan 18 2025 21:01:23
Script end

Main resources:

Total runtime0.7578 sec
Peak memory usage4,096.0000 KB
Database Queries203

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 587.7031180.8438
Module start 'content' 0.00580.5721 768.5469574.5859
Module end 'content' 0.57800.1798 1,343.1328341.3828
Script end 0.7577  1,684.5156 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.5385210.0002
Check MTime0.00140.1904210.0001
Mysql Total
Database connection0.00070.091210.0007
Mysqli_queries0.645885.21232030.0032
Looping result0.00290.38662010.0000
Template Total0.723795.520.3618
Template load0.00240.315220.0012
Template processing0.721395.176620.3606
Template load and register function0.00020.019910.0002
states
state_id_array0.00170.220910.0017
state_identifier_array0.00130.167320.0006
Override
Cache load0.00210.27321140.0000
Sytem overhead
Fetch class attribute can translate value0.00130.165230.0004
Fetch class attribute name0.00160.213170.0002
XML
Image XML parsing0.00100.134930.0003
class_abstraction
Instantiating content class attribute0.00000.003290.0000
General
dbfile0.00871.1456270.0003
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
19content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
15content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 47
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs