How to correctly write this in smarty
Posted: Sun Sep 13, 2015 6:23 pm
Hi,
I wrote some code to call in links to my page depending on what value is in the Extra Attribute. (Hope that makes sense). I am not very good with smarty, and was wondering if there was a more concise way to write the below code. There will be about 6 or so assigned variables in total. Would it be in an array? I am not sure how to write an array for something like this.
<!--Variables-->
{assign var="foo" value="foo-links"}
{assign var="bar" value="bar-links"}
{assign var="baz" value="baz-links"}
...etc
<--Statements-->
{if {page_attr key='extra1'} == 'Foo'}{menu template="quick" childrenof=$foo show_root_siblings="1" collapse="1"}{/if}
{if {page_attr key='extra1'} == 'Bar'}{menu template="quick" childrenof=$bar show_root_siblings="1" collapse="1"}{/if}
{if {page_attr key='extra1'} == 'Baz'}{menu template="quick" childrenof=$baz show_root_siblings="1" collapse="1"}{/if}
...etc
Thank you in advance.
I wrote some code to call in links to my page depending on what value is in the Extra Attribute. (Hope that makes sense). I am not very good with smarty, and was wondering if there was a more concise way to write the below code. There will be about 6 or so assigned variables in total. Would it be in an array? I am not sure how to write an array for something like this.
<!--Variables-->
{assign var="foo" value="foo-links"}
{assign var="bar" value="bar-links"}
{assign var="baz" value="baz-links"}
...etc
<--Statements-->
{if {page_attr key='extra1'} == 'Foo'}{menu template="quick" childrenof=$foo show_root_siblings="1" collapse="1"}{/if}
{if {page_attr key='extra1'} == 'Bar'}{menu template="quick" childrenof=$bar show_root_siblings="1" collapse="1"}{/if}
{if {page_attr key='extra1'} == 'Baz'}{menu template="quick" childrenof=$baz show_root_siblings="1" collapse="1"}{/if}
...etc
Thank you in advance.