{*I want to set the value of app depending on the page_ID*}
{let pageid=$node.node_id
app=' '}
{switch name=pagetester match=$pageid}
{case match=72}
{set $app='petrol'}
{/case}
{case match=71}
{set $app='pubs'}
{/case}
{case}
default case
{/case}
{/switch}
{/let}
Also, it's a good thing to make it a habit to close your let's :)
Thank you Eivind I edited the code with your suggestion (below). Unfortunately the value of the variable 'app' does not get reset to 'edu' in the switch and retains the initial value, 'test' when I output it. Logic tells me this should work, but what is missing?
I've had the same problem as this on several occasions and can't find the solution. In a similar example to Joe Hobbs version I have tested the node_id before the switch statement. When the node id is equal to 73 it enters the case:
{case match=73}
{set $app='edu'}
{/case}
However when i test the $app variable after the switch statement it is still set to its original value. It seems like the $app variable is not being set.
Can somebody try joe's code in a template file and see if it works?
Can anyone suggest a workaround to this?
Thanks again. Trevor
To conclude on this post. I used an if statement to resolve the problem I experienced with the switch (see code below). If anyone knows why the switch would not set the value of the variable whereas the if statement will I would be most interested to learn. Many thanks