Re: [SMARTY] {insert} & weird params-handling

From: Date: Fri, 26 Apr 2002 02:51:13 +0000
Subject: Re: [SMARTY] {insert} & weird params-handling
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3891@lists.php.net to get a copy of this message
"Andrei Zmievski" <andrei@ispi.net> schrieb: > Hi, > > i use several inserts within my templates. With "caching" turned off, i > received the name of the insert within the params as first parameter. > Because i do a "foreach"-loop within the insert-function for the whole > params-array I had to "array_shift" the params, to eleminate the name > of the function, which always was passed as first param. But when > "caching" is turned on, the name of the insert doesn't apear within the > params any more and my first 'real' param gets kicked. > > Any suggestions to solve this? > Params is an associative array. You should use it as such. Oh, I do. usage: {insert name=link param1=x param2=y param3=z} function smarty_insert_link ($params){ // array_shift($params); $uri = null; static $session; if (!isset($session)){ $session = ((!$GLOBALS['HTTP_COOKIE_VARS']) ? session_name().'='.session_id():''); } foreach ($params as $param => $value){ $uri .= "$param=$value&amp;"; } if (!$session){ $uri = substr ($uri, 0, -5); } return $GLOBALS['PHP_SELF']."?".$uri.$session; } I think the params should always contain the same variables. Passing different params to the same function, caused by different states of the cache, seems to me like a bug. The inserts name should be passed always or never either. Don't you think so? Norbert

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