Re: [SMARTY-DEV] Preprocessing string concatenations

From: Date: Mon, 22 Jul 2002 21:49:48 +0000
Subject: Re: [SMARTY-DEV] Preprocessing string concatenations
References: 1  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-213@lists.php.net to get a copy of this message
Concatenating strings in the templates is on the TODO list. We just need to figure out the best approach. On Fri, 19 Jul 2002, Bob Silva wrote: > Not sure if this is in the realm of Smarty processing or application design > but heres something to consider. > > Lets say we have an array where each element is named sequentially, but not > necessarily sequential in the collection: > $array1['name1'] = 'blah'; > $array1['name3'] = 'balh'; > $array1['name2'] = 'balh'; etc.... > > Lets say we also have another collection that correlates: > $array2['address3'] = 'blah'; > $array2['address1'] = 'blah'; etc... > > Nested variable parsing within smarty would be a very useful feature: > > {section name='person' loop=$array1} > Name: {$array1['name'.$person]} > Address: {$array2['address'.$person]} > {/section} > > Thats a simple example not based on real life at all. We are currently > converting Bravenet over to > a new Application Framework which uses smarty as its template engine so > changing the data model > isnt really an option. Heres a real life example of a loop we perform in our > guestbook to display > the entrys for the guestbook that I was not able to do directly within > smarty. The $options array > is the user defined question and the $entry array is the answer to the > question. The user can define > 13 questions (within $options). Both $options and $entry have other keys > defined so a straight loop > of the elements wouldnt work. Eventually I just broke the loops apart and > duplicated the code 13 > and hardcoded the key names. > > for ( $i=2; $i<16; $i++ ) { > echo > > '<tr><td>'.$options["ql".$i].'</td><td>'.$entry["q".$i]).'</td></tr>'; > } > > Not sure if its possible or reasonable to add such a thing to the smarty > compiler (nested varaible pasring) > but it would be useful to all smarty users. > > Bob Silva > Senior Developer > Bravenet.com > > > > -- > Smarty Development Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -Andrei http://www.gravitonic.com/ "Everything should be made as simple as possible, but not simpler." -- Albert Einstein

« previous php.smarty.dev (#213) next »