Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Assiging multiple variables

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
furious5
Smarty Rookie


Joined: 06 Sep 2004
Posts: 16

PostPosted: Mon Sep 06, 2004 3:02 pm    Post subject: Assiging multiple variables Reply with quote

I am currently looking in to using the smarty template engine for future development. After a few problems with the initial set up I've managed to pass a variable in to a page.

My problem now comes if I want to assign multiple variables. Maybe I am trying to do something that isn't acheivable the way I am trying to.

The set up page looks like this:
Code:
// Load Smarty library
require('c:\\php\\smarty\\Smarty.class.php');
$smarty = new Smarty;

// Pass template variables to the library
$smarty->template_dir = 'smarty/templates/';
$smarty->compile_dir = 'smarty/templates_c/';
$smarty->config_dir = 'smarty/configs/';
$smarty->cache_dir = 'smarty/cache';

// Assign variables
$smarty->assign('name','TEST2','dob','10/07/1979');

// Display the relevant template
$smarty->display('index.tpl');


The template page looks like this:
Code:
<p>Name,{$name}</p>
<p>DOB,{$dob}</p>


If I try to print the 2 variables only 1 is printed.


Last edited by furious5 on Wed May 05, 2010 10:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Sep 06, 2004 3:41 pm    Post subject: Reply with quote

Use an associative array to assign multiple values. See the Manual:

http://smarty.php.net/manual/en/api.assign.php
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development 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