Re: [SMARTY] Indexed Arrays in Config Files

Todd <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
Thanks Monte,

It works for me too now.  Maybe my browser was caching the old page.  But I
refreshed again and voila!

Thanks all.

--- Monte Ohrt <[email protected]> wrote:

> This sample works for me. Be sure config_overwrite gets set to false, 
> the behavior you are seeing is when it is true. I assume you have 
> {config_load} in the template...
> 
> Todd wrote:
> 
> >Thanks.  
> >
> >I am doing this in my code:
> >$smarty->config_overwrite = false;
> >$smarty->display('page.tpl');
> >
> >This in my config:
> >stylesheets = "styles/_common.css"
> >stylesheets = "styles/_common_interior.css"
> >stylesheets = "styles/main_nav_interior.css"
> >stylesheets = "styles/left_nav.css"
> >
> >And then this in my template:
> >{foreach from=#stylesheets# item=stylesheet_loc}
> >   <link href="{$stylesheet_loc}" rel="stylesheet" type="text/css"
> >media="screen" />
> >{/foreach}
> >
> >And I am only getting one of the four values I set in the config:
> ><link href="styles/left_nav.css" rel="stylesheet" type="text/css"
> >media="screen" />
> >
> >Thanks,
> >Todd
> >
> >--- boots <[email protected]> wrote:
> >
> >  
> >
> >>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.