Appending values to a var from within template

From: Date: Wed, 22 Aug 2001 18:29:10 +0000
Subject: Appending values to a var from within template
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1371@lists.php.net to get a copy of this message
Seid gegrüßt! In the end, I'd like to include a file depending on the value of a var which I assign some value from within my PHP script. The to be included template should be named "page.<NUM>.tpl". <NUM> would be a var. To test this, I currently use assign to assign a value from inside the template. The problem I'm having is, that I cannot figure out how to append a value. So I'm currently trying to figure out how to print "page.<NUM>.tpl" where <NUM> would be the value of a var. I'm having in my template: {assign var="assigned" value=page.$var} {$assigned} Now, when I do in PHP: $smarty->assign("var", "foo") I'd get the output "page.foo". But I'd like to have something BEHIND the $var. Hmm - I just found out that {assign var="assigned" value=page.$var.tpl} works. Hmm, I suppose that's because Smarty/PHP rightly assumes that the name of the variable "var" ends before the . of .tpl. Well, let's say this: {assign var="assigned" value=page$vartpl} $smarty->assign("var", "foo") Now, nothing is printed, because Smarty/PHP thinks that the name of the var in the {assign} is $vartpl, and thus assigning something to var doesn't have any effect. I also tried {assign var="assigned" value="page"$var"tpl"} but this results in a parse error (like I expected). Hmm - how can I do this reliably? Uhm - is it clear what I mean? :) Alexander Skwar -- How to quote: http://learn.to/quote (german) http://quote.6x.to (english) Homepage: http://www.digitalprojects.com | http://www.iso-top.de iso-top.de - Die günstige Art an Linux Distributionen zu kommen Uptime: 13 hours 4 minutes

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