Re: [SMARTY] Questions to loop and array

From: Date: Fri, 14 Nov 2003 12:54:56 +0000
Subject: Re: [SMARTY] Questions to loop and array
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10538@lists.php.net to get a copy of this message
follow the array-keys: $servers.VirtualHost.Servername, or $servers.VirtualHost.Location[0].AuthType should work. use "[123]" for numeric keys and ".abc" for alphanumeric keys. On Fri, Nov 14, 2003 at 12:47:48PM +0100, Stefan Sabolowitsch wrote: > Hi Ng, > What do I have to do, so that loop indicates the data from the array to > me? I read a VirtualHost with Pear::Config from httpd.conf > And store these with Php::Config in an array. > > $settingsSection =& $content->getItem("section", "VirtualHost"); > $Vhost = $settingsSection->toArray('phparray', array('name' => > 'Virtual')); > $smarty->assign( "servers", $Vhost); > $smarty->display('index.tpl'); > > The array has the following contents: > array(1) { > ["VirtualHost"]=> > array(4) { > ["@"]=> > array(1) { > [0]=> > string(12) "127.0.0.1:80" > } > ["DocumentRoot"]=> > string(14) "/usr/share/www" > ["ServerName"]=> > string(15) "www.test.com" > ["Location"]=> > array(2) { > [0]=> > array(3) { > ["@"]=> > array(1) { > [0]=> > string(5) "/test" > } > ["AuthType"]=> > string(5) "basic" > ["Require"]=> > string(11) "group admin" > } > [1]=> > array(3) { > ["@"]=> > array(1) { > [0]=> > string(6) "/admin" > } > ["AuthType"]=> > string(5) "basic" > ["Require"]=> > string(12) "group stefan" > } > } > } > } > > Index.tpl looks as follows. > > ~snip > > {section name=server loop=$servers} > <TR> > <TD VALIGN=TOP BGCOLOR=#D9E1E8 NOWRAP> > <A HREF="viewserver.php?servername={$servers[server].ServerName}" > TITLE="View virtual server details"><IMG SRC="gfx/zoom.gif" > BORDER=0> > </A> > <A HREF="editserver.php?servername={$servers[server].servername}" > TITLE="Edit virtual server"><IMG SRC="gfx/edit.gif" > BORDER=0></A> > {$servers[server].servername}</TD> > > ~snap > > Please someone can explain to me exactly, how I get array to the > individual elements read. > > Thanks for each assistance > > Cheers > > Stefan > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

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