|
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 |
ilir Smarty Rookie
Joined: 20 Apr 2003 Posts: 16 Location: NYC
|
Posted: Sun Apr 20, 2003 5:37 am Post subject: Making {literal} conditional |
|
|
Hi everyone, this is a nice forum!
I am trying to display a piece of JavaScript (which is enclosed in {literal} tags) conditionally. It doesn't work, for some reason, and I know it shouldn't since anything within {literal} should not be interpreted by Smarty, but I can't think of another way.
This is what I have in my page.tpl file:
Code: |
{if $results neq null}//There are DB results
{literal}
<script language="JavaScript"...> </script>
{/literal}
{/if}
|
I tried using {capture} but it doesn't work. This is what I did with it:
Code: |
{capture name=myTable}
{literal}
<script language="JavaScript"...> </script>
{/literal}
{/capture}
{if $results neq null}//There are DB results
{$smarty.capture.myTable}
{/if}
|
But when I run it, I get:
Quote: | Fatal error: Smarty: [in page.tpl line 145]: syntax error: $smarty. is an unknown reference (Smarty_Compiler.class.php, line 1771) in /home/virtual/siteXX/fst/var/www/html/site/Smarty_Compiler.class.php on line 1824 |
Can anyone suggest an alternative to this?
Thanks in advance,
Ilir. _________________ The real problem is not whether machines think but whether men do.
- B. F. Skinner |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sun Apr 20, 2003 11:53 am Post subject: |
|
|
i tested both of your examples and they work 100% with 2.5.0 and with the cvs-version. *shrug* |
|
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
|