RE: [SMARTY] Variables in variables

From: Date: Mon, 04 Nov 2002 14:44:41 +0000
Subject: RE: [SMARTY] Variables in variables
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6320@lists.php.net to get a copy of this message
<html> ... {assign var="name" value="Santa"} {assign var="from" value="Your Friends At CutCo"} {capture name=greeting}Hello {$name}, nice to meet you, from {$from}{/capture} {$smarty.capture.greeting} ... </html> will print: Hello, Santa, nice to meet you, from Your Friends At CutCo Honestly though, its best if you assemble variables like that in php: <? $name = "Santa"; $from = "Your Friends At CutCo"; ... smarty instantiation here ... $smarty_object->assign("greeting", "Hello $name, nice to meet you, from $from"); ?> and then access them in your templates: {$greeting} -- Josh -----Original Message----- From: Marc Debold [mailto:Marc.Debold@tec-systems.de] Sent: Thursday, October 31, 2002 10:48 AM To: smarty-general@lists.php.net Subject: [SMARTY] Variables in variables Hello there, I'm trying to have some vars within another var, but don't know how to do it. I want to make a customizable welcome-page, that can contain e.g. the name of the user inserted via smarty varaible. Example: php: <?php $name = "Santa"; $greet = "Hello {$name}, nice to meet you again"; ... ?> template: <html> ... {$greet} ... <html> output: <html> ... Hello Santa, nice to meet you again ... </html> Is that possible without using several template files? I have n customers, that have m customers, and each wants another welcome page. Best regards, Marc -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#6320) next »