以下是PHP程序<?php
require_once("conn_inc.php");
require_once("smarty_inc.php");
if ($_REQUEST['id']) {
$id=$_REQUEST['id'];
$query=mysql_query("select * from new where id='$id' ");
$row=@mysql_fetch_array($query);
$content=$row['content'];
}
$smarty->assign("content",$content);
$smarty->display("new_update.tpl.html");
?>以下是模板程序<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="fckeditor/fckeditor.js"></script> 
<form action="" method="POST">
<table border="1" align="center" width="70%">
<tr>
<td>内容:</td>
<td>
{literal}
<script type="text/javascript"> 
var oFCKeditor = new FCKeditor( 'content' ) ; 
oFCKeditor.BasePath = "fckeditor/" ; 
oFCKeditor.Height = 300 ; 
oFCKeditor.Value = "{$content}" ; 
oFCKeditor.Create() ; 
</script> 
{/literal}
</td>
</tr>
<tr>
<td colspan="2"><center><input name="submit" value="更新提交" type="submit"></center></td>
</tr>
</table>
</form>
当我通过
$smarty->assign("content",$content);
把值传送给模板变量{$content}的时候在模板页面中不显示
当我查看原程序的时候发现
oFCKeditor.Value = "{$content}" ; 中对以的有值,大家看下我哪里写错了!

解决方案 »

  1.   

    {literal}
    {/literal}
    用了这个标签,不支持变成输出!
      

  2.   

    如楼上所说
    问题应该就出现在{literal}
      

  3.   

    被{literal}包上之后,
    {$content}就不被编译了。看看这样如何:<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="fckeditor/fckeditor.js"></script> 
    <form action="" method="POST">
    <table border="1" align="center" width="70%">
    <tr>
    <td>内容:</td>
    <td>
    {literal}
    <script type="text/javascript"> 
    var oFCKeditor = new FCKeditor( 'content' ) ; 
    oFCKeditor.BasePath = "fckeditor/" ; 
    oFCKeditor.Height = 300 ; 
    {/literal}
    oFCKeditor.Value = "{$content}" ; 
    {literal}
    oFCKeditor.Create() ; 
    </script> 
    {/literal}
    </td>
    </tr>
    <tr>
    <td colspan="2"><center><input name="submit" value="更新提交" type="submit"></center></td>
    </tr>
    </table>
    </form>
      

  4.   

    Literal 标签区域内的数据将被当作文本处理,此时模板将忽略其内部的所有字符信息. 该特性用于显示有可能包含大括号等字符信息的 javascript 脚本. 当这些信息处于 {literal}{/literal} 标签中时,模板引擎将不分析它们,而直接显示.