[prev in list] [next in list] [prev in thread] [next in thread]
List: smarty-general
Subject: [smarty] Re: referencing associative arrays using template variables
From: "Jason Sweat" <sweatjejm () home ! com>
Date: 2001-06-29 0:10:29
[Download RAW message or body]
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 leave-smarty-700385W@lists.ispi.net
> Visit Smarty's homepage at http://www.phpinsider.com/php/code/Smarty/
---
You are currently subscribed to smarty as: smarty@progressive-comp.com
To unsubscribe send a blank email to leave-smarty-700385W@lists.ispi.net
Visit Smarty's homepage at http://www.phpinsider.com/php/code/Smarty/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic