Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

eval of a return value

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
datenpunk
Smarty Rookie


Joined: 17 May 2003
Posts: 6

PostPosted: Tue May 20, 2003 12:27 am    Post subject: eval of a return value Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue May 20, 2003 2:12 am    Post subject: Reply with quote

{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 Wink

{eval var=$content assign="content"}
{eval var=$content assign="content"}

{$content}
Back to top
View user's profile Send private message Visit poster's website
datenpunk
Smarty Rookie


Joined: 17 May 2003
Posts: 6

PostPosted: Tue May 20, 2003 11:14 am    Post subject: Reply with quote

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 Smile

Daniel Khan
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu May 22, 2003 7:13 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP