I have a smarty if statement as follows:
<{if $page->getURLName() eq 'big-issues' or $page->getURLName() eq 'polls' or $page->getURLName() eq 'what-we-do' or $action eq 'events' or $action eq 'blogs' or $action eq 'news'}>
I have to compare the same statements several time in the template. And its really tedious to ugly to repeat this statements several times. I know I can cache a statements and reuse it many times but I was looking if its possible to do something like this:
<{if $page->getURLName() eq 'big-issues' or 'polls' or 'what-we-do' or 'events' or $action eq 'blogs' or 'news'}>
like in PHP we could do:
$url = array ("big-issues","polls","what-we-do");
$needle = $page->getURLName();
if(in_array($needle, $centered)) {
//Do something
}
Please note that I dont have access to php code for the template so can only use smarty. Any suggestion will be highly appreciated.
Cheers.
Actually this is the solution I came up with.
NOTE: In my template I have to use <{}> instead of {} to start smarty. Its just how the template is set up.
Now I could check many times in my HTML the same statements without messing up the code.
Check this: http://www.smarty.net/forums/viewtopic.php?p=48466
And this for assign to array within templates: How to assign an array within a smarty template file?
Should be something like this: