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

Making {literal} conditional

 
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
ilir
Smarty Rookie


Joined: 20 Apr 2003
Posts: 16
Location: NYC

PostPosted: Sun Apr 20, 2003 5:37 am    Post subject: Making {literal} conditional Reply with quote

Hi everyone, this is a nice forum! Smile

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? Rolling Eyes

Thanks in advance,

Ilir.
_________________
The real problem is not whether machines think but whether men do.
- B. F. Skinner
Back to top
View user's profile Send private message MSN Messenger
messju
Administrator


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

PostPosted: Sun Apr 20, 2003 11:53 am    Post subject: Reply with quote

i tested both of your examples and they work 100% with 2.5.0 and with the cvs-version. *shrug*
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