Re: Append

From: Date: Thu, 04 Dec 2003 20:23:50 +0000
Subject: Re: Append
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10635@lists.php.net to get a copy of this message
Well, if all you're doing is getting two arrays into your template, I'd suggest using assign instead of append. append is only for appending to an existing array. Then in your template, you can make two sections. (Note, you can also use foreach instead of section if the array is associative.) Example: php $smarty->assign('array1', array(1, 2, 3)); $smarty->assign('array2', array('a', 'b', 'c')); tpl <h3>Section 1</h3> {section name=section1 loop=$array1} {$array1[section1]}<br/> {/section} <h3>Section 2</h3> {section name=section2 loop=$array2} {$array2[section2]}<br/> {/section} OR <h3>Section 1</h3> {foreach from=$array1 item=val1} {$val1}<br/> {/foreach} <h3>Section 2</h3> {foreach from=$array2 item=val2} {$val2}<br/> {/foreach} Mark Dyer wrote:
Hello, I am using smarty for the first time and I am passing an array to my template using the append(array) function. I than loop the function and display the formated content. This works fine for one section but how do I did it if I want to pass more than one array for displaying more than 1 section. do I need togo append(ArrayName,Array) append(ArrayName2,Array2). If so, How is this than referenced. It would be nice is the smarty documents had more examples like php.net. Mark NZ


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