Re: Re[2]: [SMARTY] switch instruction in smarty?

From: Date: Fri, 21 Oct 2005 20:55:58 +0000
Subject: Re: Re[2]: [SMARTY] switch instruction in smarty?
References: 1 2 3 4 5  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13113@lists.php.net to get a copy of this message
On Oct 21, 2005, at 3:35 PM, pbaker wrote:
and if that user change by hand url like '?cmd=bug' (bug is not in my if rule!) i want to move him on default page ...
if you use assign: {assign var="tab" value=$smarty.get.cmd} and the querystring is ?cmd=bug or ?cmd=qwerty then $tab will not be empty. it will be the value "bug" or "qwerty". That was why one of the suggestions was to use a "fall-through" for the main/default value. (of course, that's not as simple when the default should appear first in the template). You could create a simple lookup table such that the keys and values are the same. If the key isn't found then null/emptystring will be returned: <?php //... myMap = { "a"=>"a","b"=>"b","c"=>"c" }... $smarty->assign( "lookup", $myMap ); ?> ... {assign var="tab" value=$smarty.get.cmd} {assign var="realTab" value=$lookup[$tab]} -daniel -- http://www.hedrick.org/daniel?sig

« previous php.smarty.general (#13113) next »