Re: referencing associative arrays using template variables

From: Date: Fri, 29 Jun 2001 00:10:29 +0000
Subject: Re: referencing associative arrays using template variables
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1083@lists.php.net to get a copy of this message
On second thought, passing in a string would mean the template would have to be compiled each time, no efficiencies gained there. :( ----- Original Message ----- From: "Jason Sweat" <sweatjejm@home.com> To: "Smarty" <smarty@lists.ispi.net> Sent: Thursday, June 28, 2001 6:46 PM Subject: [smarty] Re: referencing associative arrays using template variables > Had a couple of more thoughts: > First, it was relatively trivial to reorder the array, you can to > $t->assign(array( > 'DATA' => assos_to_idx($data, $xml), > 'XML' => $xml)); > using this function: > function assos_to_idx($assos, $keys) > { > $i = 0; > while( $i < count($assos)) { > $k = 0; > while ( $k < count($keys)) { > $out[$i][$k] = $assos[$i][$keys[$k]]; > $k++; > } > $i++; > } > return $out; > } > > Second thought: > With a relatively simple change I could implement recursive template in my > script. What I would need is a Smarty::displays and ::fetchs function that > take a first argument that is a string containing the template rather than > the name of the template. (This would also be useful for retrieving > templates from a database, run the query to retrieve the template and used > the result in a $temp->displays($result_from_db...)) > > I could then have a template with a section that runs over the keys array > and generates the final template that I use with the $DATA array to publish > the final xml document. > > Jason > > ----------------- > > My inital instinct was to try to write something like > > {$DATA[data].{$XML[xml]}} > > with the inner smarty brackets indicating a template variable that should > be > > evaluated before being applied as the assosiative key. > > Yep, that would be peachy, except that is not quite possible since it > requires recursive template evaluation. I'll try to keep it in the back > of my mind in case a bright idea decides to emerge out of there one day. > > -Andrei > * There is no knowledge that is not power. * > > > > --- > You are currently subscribed to smarty as: sweatjejm@home.com > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/

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