Re: [SMARTY] Building arrays within templates

From: Date: Fri, 04 Jul 2003 09:38:23 +0000
Subject: Re: [SMARTY] Building arrays within templates
References: 1 2 3 4  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9837@lists.php.net to get a copy of this message
"messju mohr" writes: > there is already sth. like that in the contrib-section of the > smarty-website. see: > > http://smarty.php.net/contribs/plugins/view.php/function.assign_array.phpÊ_¶90@î@!¦™}. > mM I seem to recall looking at this a while back, now you remind me. What it can;t handle (and I'm looking for) is: {assign array="data" value="Line1"} {assign array="data" value="Line2"} {assign array="data" value="Line3"} .. which is what you'd expect {assign var="data[]" value="Line1"} {assign var="data[]" value="Line2"} {assign var="data[]" value="Line3"} .. to do but is confusing in the array syntax, so I need a rethink anyway. > another plugin accomplishing this is discussed here: > http://www.phpinsider.com/smarty-forum/viewtopic.php?t=220 This is a much better approach - I looked at implementing this myself but didn't get around to it. It still doesn't handle appending to the array but that ought to be a small tweak to the regexp to handle [] - except that smarty uses . for arrays not [] so it isn't consistent. So, if: {assign var="data.1" value="Line1"} .. is equivalent to PHP code $data[1] = "Line1" .. then what would make sense as Smarty syntax for the PHP code $data[] = "Line1" ..? Logically {assign var="data." value="Line1"} .. makes sense but is its meaning obvious? Mark Rogers, More Solutions Ltd

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