Re: Smarty setting arrays

From: Date: Thu, 01 Nov 2001 14:20:18 +0000
Subject: Re: Smarty setting arrays
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1780@lists.php.net to get a copy of this message
On Thu, 1 Nov 2001, Roberto Berto wrote: > I developed a routine and send it to Monty and Andrei. > > The functions strip strings and make arrays from it. Like this: > {command users@name="Roberto" users@age="18" options@city@NY="0" > options@city@Chicago="1"} come > > $users = array("name" => "Roberto", "age" => > "18"); > > $options = array("city" => array("NY"=>0,"chicago"=>1)); > > I use this with "insert" functions, but now I added to "custom" functions > too and maybe Andrei or Monte can add this string to array in others things > of Smarty like: insert, custom functions, assign. > > With insert and custom functions are easy. But with assign to string we'll > use {assign val="some" and value="me"} but with arrays we need to change to > {assign array="some" something@foo="123" other@foo@me="666"} > > > Now, I need to ask: > Vars doesnt work with {insert}? > > I try: > > {assign var="thing" value="666"} > {insert name="form" element=$thing} > > And doesnt work. > > Why? > Since the point of using a template system is to separate as much as possible the business logic from the actual layout, what is the advantage of assigning variables in the template itself rather than in the actual PHP script that calls this template ? Maybe I'm missing something here, but the normal way would be to make it backwards to what you are trying to do here - set the array or variable on the PHP script, and use Smarty to set the layout options for the elements in this array / variable. Can you elaborate on why you would need something like this ? Cheers, Joao -- João Prado Maia <jpm@phpbrasil.com> http://phpbrasil.com - php com um jeitinho brasileiro -- Precisando de consultoria em desenvolvimento para a Internet ? Impleo.net - http://impleo.net/?lang=br

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