Re: [SMARTY] insert: problem with a variable name attribute

From: Date: Thu, 08 Aug 2002 17:59:24 +0000
Subject: Re: [SMARTY] insert: problem with a variable name attribute
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5623@lists.php.net to get a copy of this message
On 8 Aug 2002 at 15:59, Thomas Schulz wrote: > Hello, > > i try the following smarty code in a template (tool.tpl) ... > > {foreach key=name item=plugin from=$view.main} > plugin name: {$name}<br> > {insert name=$name view=$plugin.view style=$plugin.style} > {/foreach} Don't expect this to work. {insert} is not a "normal" smarty function but treated special as it is used for data that shall not be cached. > > ...and become an error: > Parse error: parse error, unexpected T_STRING, expecting ')' in d:\... > \templates_c\%%-62\%%-622499225\tool.tpl.php on line 4 > > > --- Line 3-4 in the compliled template --------------------------- > > <?php $this->_load_plugins(array( > array('insert', '$this->_tpl_vars['name']', > 'tool.tpl', 18, false), Smarty developers did not plan to make the "name" attribut dynamic. Because of insert's special meaning, 'name' has to be a static value. > ... > ------------------------------------------------------------------- > > The assigned array $view looks like that: > > $view ['main'] ['tool'] ['view'] = 'index'; > $view ['main'] ['tool'] ['style'] = 'main'; > > {insert name=tool view=$plugin.view style=$plugin.style} works fine. Of course - 'tool' is a static value. > > Is this a Bug or a missed Feature? > Possible Workaround? Neither nor, its expected behavior. Don't use insert here. -- Ferdinand Beyer <fbeyer@clickhand.de>

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