Page 1 of 1

Smarty eval - what is it for?

Posted: Fri Jun 01, 2007 10:09 pm
by Anastasis
The default news module detail template includes the code:

Code: Select all

 {eval var=$entry->content}
to display the news content.

However just having:

Code: Select all

{$entry->content}
also displays the news content.

So what is "eval" for? The Smarty manual says:
{eval} is used to evaluate a variable as a template. This can be used for things like embedding temaplate tags/variables into variables or tags/variables into config file variables.

If you supply the special "assign" attribute, the output of the {eval} function will be assigned to this template variable instead of being output to the template.
but I don't understand how this works in practice although it looks like it could be useful. Is it? And what difference does it make in the news module detail template? It appears to have none.

Re: Smarty eval - what is it for?

Posted: Tue Jun 05, 2007 9:34 am
by Anastasis
Not that it is a show stopper but has anyone got any thoughts on this (see post above)?

Re: Smarty eval - what is it for?

Posted: Tue Jun 05, 2007 1:40 pm
by calguy1000
the eval statement in the News module templates is designed so that you can put smarty expressions, etc in your summary and detail content.  This would be useful for (for example) allowing comments on News articles, adding {image} tags, or embedding pieces of albums, etc.  a whole world of stuff.

If you don't use any smarty stuff in your news summaries, or detail you can probably get away with leaving the eval statements out.

Re: Smarty eval - what is it for?

Posted: Tue Jun 05, 2007 3:40 pm
by Anastasis
calguy1000 wrote: the eval statement in the News module templates is designed so that you can put smarty expressions, etc in your summary and detail content.  This would be useful for (for example) allowing comments on News articles, adding {image} tags, or embedding pieces of albums, etc.  a whole world of stuff.

If you don't use any smarty stuff in your news summaries, or detail you can probably get away with leaving the eval statements out.
Thanks - sounds useful although I don't really understand how this would work in practice. Are there any examples of this?