Discussion:
[SMARTY] template variables in template variables
G
2002-04-13 07:06:02 UTC
Permalink
Hello,

Here's what I'm trying to do:


$text = "ip={$smarty.server.HTTP_REFERER}";

$smarty->assign('text', $text);

$smarty->fetch('template.tpl');


So any template variables/functions in variable contents would be parsed by
smarty. Needless to say, it doesn't work. Is there a way to accomplish this?

Thanks,
Gerard
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Monte Ohrt
2002-04-13 16:03:33 UTC
Permalink
Yep, check out the eval function.

http://www.phpinsider.com/php/code/Smarty/docs/language.custom.functions.html#LANGUAGE.FUNCTION.EVAL

Monte
Post by G
Hello,
$text = "ip={$smarty.server.HTTP_REFERER}";
$smarty->assign('text', $text);
$smarty->fetch('template.tpl');
So any template variables/functions in variable contents would be parsed by
smarty. Needless to say, it doesn't work. Is there a way to accomplish this?
Thanks,
Gerard
--
Monte Ohrt <***@ispi.net>
Director of Technology, ispi Inc.
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ivo Jansch
2002-04-15 12:17:49 UTC
Permalink
Hello Monte,
Post by Monte Ohrt
Yep, check out the eval function.
Nice function!

In the examples, I saw usage is like this:
{eval var="foo"}

Can it also be used like this:

{$foo|eval}

?

This is more friendly and doesn't cloud my templates with {eval}
statements. (And also because then I can apply it as default modifier to
every template variable, so it's transparent if the contents of the
variable contains nested stuff or not.)

Greetings,
Ivo
--
Ivo Jansch <***@ibuildings.nl>
ibuildings.nl BV - information technology
http://www.ibuildings.nl
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Monte Ohrt
2002-04-15 16:40:37 UTC
Permalink
If you create an eval modifier, I suppose it would work :-)
Post by Ivo Jansch
Hello Monte,
Post by Monte Ohrt
Yep, check out the eval function.
Nice function!
{eval var="foo"}
{$foo|eval}
?
This is more friendly and doesn't cloud my templates with {eval}
statements. (And also because then I can apply it as default modifier to
every template variable, so it's transparent if the contents of the
variable contains nested stuff or not.)
Greetings,
Ivo
--
Monte Ohrt <***@ispi.net>
Director of Technology, ispi Inc.
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Jason Sweat
2002-04-14 04:11:03 UTC
Permalink
You can't access the $smarty variables in your script,
did you really mean

$test = 'ip='.$_SERVER['HTTP_REFERER'];
?

Jason


----- Original Message -----
From: "G" <***@interfold.com>
To: <smarty-***@lists.php.net>
Sent: Saturday, April 13, 2002 2:06 AM
Subject: [SMARTY] template variables in template variables
Post by G
Hello,
$text = "ip={$smarty.server.HTTP_REFERER}";
$smarty->assign('text', $text);
$smarty->fetch('template.tpl');
So any template variables/functions in variable contents would be parsed by
smarty. Needless to say, it doesn't work. Is there a way to accomplish this?
Thanks,
Gerard
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...