Re: Appending values to a var from within template

From: Date: Wed, 22 Aug 2001 21:44:38 +0000
Subject: Re: Appending values to a var from within template
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1372@lists.php.net to get a copy of this message
Yes, and there is no good way to do it right now... we'll have to think of something. On Wed, 22 Aug 2001, Alexander Skwar wrote: > 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 > > --- > You are currently subscribed to smarty as: andrei@ispi.net > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ -Andrei Give a man a fish; you have fed him for today. Teach a man to use the Net and he won't bother you for weeks. -Author unknown

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