|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
datenpunk Smarty Rookie
Joined: 17 May 2003 Posts: 6
|
Posted: Tue May 20, 2003 12:27 am Post subject: eval of a return value |
|
|
Hello,
Following problem:
A script gets it's values from the script using assign.
These values may contain functions.
So I use {eval var=$content}
But now $content may also contain a function (recursion).
Is it possible to parse the return value from eval again?
Thanks in advance
Daniel Khan |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue May 20, 2003 2:12 am Post subject: |
|
|
{eval} evaluates a variable as if it were a template. If you want to evaluate the output of eval as a template, just repeat it. I can't think of why you'd want to do something like that. You might re-evaluate what you're doing in the first place, there has to be an easier way
{eval var=$content assign="content"}
{eval var=$content assign="content"}
{$content} |
|
Back to top |
|
datenpunk Smarty Rookie
Joined: 17 May 2003 Posts: 6
|
Posted: Tue May 20, 2003 11:14 am Post subject: |
|
|
After having some sleep I now use
$data = smarty_function_eval($params, $smarty); inside the function to get the behavior I want.
The reason why I want to do this:
Inside the CMS the editor can add an article:
{article id=455}
Inside this article may be nested images, links a.s.o.
So I need a recursive evaluation.
Am I on the wrong track?
Thanks
Daniel Khan |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu May 22, 2003 7:13 am Post subject: |
|
|
1. write a resource-plugin for your articles, that takes the id as a resource name.
after that you can do (include file="article:1234"} everywhere in your templates
2. write a convinience-function like
Code: | function smarty_function_article($params, &$smarty)
{
return $smarty->fetch('article:'.$params['id']);
}
|
after that you can do {article id=1234} everywhere in your templates
now your article is a template and can contain code like
{link id=foo} ..{img topic=bar} ... {article id=456} ....
i think this is the kind of recursion you want.
greetings
messju |
|
Back to top |
|
|
|
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
|