|
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 |
Sim00n Smarty n00b
Joined: 01 Feb 2010 Posts: 3
|
Posted: Sat Jul 10, 2010 6:43 pm Post subject: Variable from PHP and comiling problem. |
|
|
Hi guys. I got problem with compiling of tpl file.
I'm creating "code's hosting" - something like google documents but for programmers to store their codes. Right now I'm reding content from file and assignig it to a variable to send it to tpl like that:
Code: |
$smarty->assign("Code", $content);
|
and than in tpl:
Code: |
<textarea class="field" style="width: 95%; height: 250px;" wrap="off" name="name" cols="90" rows="90"> {$Code} </textarea>
|
The problems stars when variable Codes contains some smarty parts like {$if} etc. so I tried to use {literal} functions to "turn off" this code in compiling but the output was "{$Code}" instead of the reall code that i want to show.
The question is how to make it work
Regards, Sim00n. |
|
Back to top |
|
ChrisFah Smarty Pro
Joined: 02 Nov 2009 Posts: 159 Location: Traun, Austria
|
Posted: Sat Jul 10, 2010 7:30 pm Post subject: |
|
|
Hi,
try this(not tested):
Before assigning it to a smarty var,
Code: | $content = '{literal}'.$content.'{/literal}';
$smarty->asign('Code', $content);
|
Code: | <textarea class="field" style="width: 95%; height: 250px;" wrap="off" name="name" cols="90" rows="90"> {$Code} </textarea> |
Now, everything between {literal} shoult be untouched.
Regard, Chris |
|
Back to top |
|
douglassdavis Smarty Junkie
Joined: 21 Jan 2008 Posts: 541
|
Posted: Sat Jul 10, 2010 7:49 pm Post subject: Re: Variable from PHP and comiling problem. |
|
|
does {$Code|escape} work?
Just outputting a var containing smarty code shouldn't really be a problem, so I'm not sure exactly what the problem is otherwise. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Jul 10, 2010 10:45 pm Post subject: |
|
|
smarty template syntax in a variable should have no problems. it should not compile as a template unless you eval the variable. it should be treated as plain text? |
|
Back to top |
|
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Tue Jul 13, 2010 8:38 pm Post subject: Thats not true. |
|
|
Few comments:
{$if} is NOT a part of Smarty related things.
You are confusing with {if}, or mistyped it.
Anything you put in $content should appear as {$Code}.
So, I guess, your PHP's value of $content is wrong.
Hence, appending {literal} tags are useless.
Just debug what is wrong with $content. |
|
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
|