Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Using assign to create arrays in a template

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
cwsaylor
Smarty Rookie


Joined: 17 Jun 2003
Posts: 5

PostPosted: Thu Jun 19, 2003 7:34 pm    Post subject: Using assign to create arrays in a template Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu Jun 19, 2003 7:57 pm    Post subject: Reply with quote

no this doesn't work. you would have to write your own append-plugin.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cwsaylor
Smarty Rookie


Joined: 17 Jun 2003
Posts: 5

PostPosted: Thu Jun 19, 2003 8:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Jun 19, 2003 8:51 pm    Post subject: Reply with quote

Would it be suitable to load the array from a config file?
Back to top
View user's profile Send private message
cwsaylor
Smarty Rookie


Joined: 17 Jun 2003
Posts: 5

PostPosted: Fri Jun 20, 2003 1:29 am    Post subject: Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Jun 20, 2003 2:37 am    Post subject: Reply with quote

You may want to take a look at this thread which has a slightly more advanced look at assignment.

EDIT:

I almost forgot about this thread: populate an associative array in tpl
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP