Re: passing an array to an included template

From: Date: Thu, 02 May 2002 16:13:16 +0000
Subject: Re: passing an array to an included template
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3995@lists.php.net to get a copy of this message
"Jens Lehmann" <newsgroup@developerforum.net> schrieb im Newsbeitrag news:20020502152034.28016.qmail@pb1.pair.com... > What you're doing is including a template several times. I just want > to include this template once. My only problem is to parse an array > to this template (which in fact should be easy?). I don't include one template several times. I include several different templates by passing a value as filename to the include. {include file=$assignedBlocks.left[block].template} ;-P > The template which needs to be included is a small navigation bar. > I want to pass an array of strings > e.g. array("Home","Forums","Java","Entry 2342"). > > To make it easier understandable I can reduce my question to > assigning an array within Smarty (which is the same problem). > > If I do assign("test",array("foo1","foo2")) it won't work > (without > my change in the Smarty Source), because Smarty puts quotes > around unquoted strings and array("foo1","foo2") is regarded as > a string. So how can I assign an array within Smarty without this > change in the source code? Ehm, I'm sorry. Maybe i'm too stupid, but your only problem is to assign a simple array to smarty? if so, just try this: your script: $test = array('foo1', 'foo2'); $smarty->assign ('test', &$test); your template: {include file="foo.tpl" some_array=$test} > Hope the problem is clear now. ;-) Not really. :-D If the upper solution doesn't work, you really should post the related parts of your source and template. Greetings, Norbert

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