|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
cwsaylor Smarty Rookie
Joined: 17 Jun 2003 Posts: 5
|
Posted: Thu Jun 19, 2003 7:34 pm Post subject: Using assign to create arrays in a template |
|
|
I want to create arrays in the template file and then pass them back to the header using an inlclude. The goal is not to have to assign the arrays from the php file. Is this possible?
Here is something like what I want to accomplish. Note: This does not work.
Code: |
{assign var="scripts[]" value="one"}
{assign var="scripts[]" value="two"}
{include file="header.tpl" pagetitle="testing" scripts=$scripts }
{$content}
{include file="themes/default/footer.tpl.html" }
|
The header file looks like this.
Code: |
<html>
<head>
<title>{$pagetitle}</title>
</head>
<body>
{$scripts[0]}<br>
{$scripts[1]}<br>
|
Thanks for your help,
Chris |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu Jun 19, 2003 7:57 pm Post subject: |
|
|
no this doesn't work. you would have to write your own append-plugin. |
|
Back to top |
|
cwsaylor Smarty Rookie
Joined: 17 Jun 2003 Posts: 5
|
Posted: Thu Jun 19, 2003 8:10 pm Post subject: |
|
|
I see that. I just checked the code for the assign plug-in. Hard to imagine that no one has wanted to do this before. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Jun 19, 2003 8:51 pm Post subject: |
|
|
Would it be suitable to load the array from a config file? |
|
Back to top |
|
cwsaylor Smarty Rookie
Joined: 17 Jun 2003 Posts: 5
|
Posted: Fri Jun 20, 2003 1:29 am Post subject: |
|
|
That's another layer that I don't want to introduce. My goal is to put page specific javascripts and meta tags back up into the header file. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|