Re: [SMARTY] Indexed Arrays in Config Files

boots <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
Actually, Smarty does allow for such a thing.

http://smarty.php.net/manual/en/variable.config.overwrite.php

Once they are setup, you can also access the array via the $smarty
reserved variable {$smarty.config.foo}

HTH

--- Todd <[email protected]> wrote:

> Fair enough.  I am new to Smarty and playing around a bit, but also
> trying to
> get something done.
> 
> Each page in my site has one or more stylesheets depending on where
> in the site
> it is and what design elements it contains.  I want to be able to
> dynamically
> add each stylesheet as necessary. So I was imagining template code
> like this
> (assuming arrays worked from config files):
> 
> {foreach from=#stylesheets# item=stylesheet_loc}
>   <link href="{$stylesheet_loc}" rel="stylesheet" type="text/css"
> media="screen" />
> {/foreach}
> 
> How could I implement that without assigning the array
> ($smarty->assign('stylesheets', array("css1.css", "css2.css"))) to in
> my php
> code?
> 
> Thanks,
> Todd
> 
> --- Howard Katz <[email protected]> wrote:
> 
> > Todd,
> > 
> > Typically, it is better to let us know what you want to DO with
> > Smarty rather than possibly force an inappropriate method on the
> > solution.
> > 
> > So without further insight to what you are trying to do, I will
> > attempt to answer your question. 
> > 
> > I do not think that Smarty allows for arrays in configuration
> files.
> > Smarty templates are PHP aware and you can stuff arrays into them,
> > however. So, you could have the array in PHP and just feed it into
> > the template.
> > 
> > <?php
> > 
> > require('Smarty.class.php');
> > 
> > $employee_id_ary[1525]='Susan Schwartz';
> > $employee_id_ary[1343]='Ashish Khadalanwal';
> > $employee_id_ary[2452]='Joe Smith';
> > 
> > $smarty = new Smarty();
> > $smarty->assign('employee_id_ary', $employee_id_ary);
> > $smarty->assign('id', 1525);
> > $smarty->display('employee_tpl.html');
> > 
> > 
> > ?>
> > 
> > template file named employee_tpl.html:
> > 
> > {*this is the Smarty Template*}
> > Employee name = {$employee_id_ary[$id]}
> > 
> > Output:
> > Employee name = Susan Schwartz
> > 
> > 
> > 
> > 
> > So, does that allow you enough flexability?
> > 
> > -Howard
> > --- Todd <[email protected]> wrote:
> > 
> > > Are numerically indexed arrays supported in config files?  If
> not,
> > > what is a
> > > good alternative?
> > > 
> > > Thanks,
> > > Todd
> > > 
> > > -- 
> > > Smarty General Mailing List (http://smarty.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > 
> > > 
> > 
> > 
> > 
> > 
> > 	
> > 		
> > ______________________________________________________
> > Click here to donate to the Hurricane Katrina relief effort.
> > http://store.yahoo.com/redcross-donate3/
> > 
> 
> -- 
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



	
		
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.