 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| 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: 124 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 Elite
Joined: 21 Jan 2008 Posts: 263
|
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: 5545 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? _________________ Monte
http://www.phpinsider.com/
http://mohrt.blogspot.com/ |
|
| Back to top |
|
bimal Smarty Elite

Joined: 19 Apr 2007 Posts: 345 Location: Kathmandu, Nepal
|
|
| 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
|