求教Smarty模板

浏览:881 发布日期:2014/11/23 分类:求助交流
Smarty的配置如下:
require_once('./Library/Smarty/Smarty.class.php') ;//引入文件类
$swl = new Smarty(); //实例化
$swl->template_dir="template"; //指定模版存放目录
$swl->compile_dir="Cache/php"; //指定编译文件存放目录
$swl->config_dir="Cache/conf"; //指定配置文件存放目录
$swl->cache_dir="Cache"; //指定缓存存放目录
$swl->caching=false; //开启缓存(true表示启用缓存)
$swl->left_delimiter="{:"; //指定左标签
$swl->right_delimiter=":}"; //指定右标签

下面的index.php和one.php的变量解析都OK,而view.php出错。index.php
<?php

    require_once 'Library/header.php';
    //require_once('/include/footer.php');
    $name="OK11";
    $swl->assign('name',$name);
    $swl->display("index.html");
?>
index.html
<html>
<title>{:$name:}</title>
    <body>
        <h1>{:$name:}</h1>
        <a href="view.php?act=kakakak">VIEW</a>
        <br>
        <a href="one.php?act=kakakak">VIEW</a>
    </body>
</html>
one.php
<?php

    require_once 'Library/header.php';
    //require_once('/include/footer.php');
    $name=$_GET['act'];
    $pa="23";
    $swl->assign('napme',$name);$swl->assign('pa',$pa);
    $swl->display("read.html");
?>
read.html
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="./public/haha.css">
</head>
<body>
        <h1>{:$napme:}</h1>

        adfasdfadf{:$napme:}adf{:$pa:}
    </body>
</html>
view.php
<?php

    require_once 'Library/header.php';
    //require_once('/include/footer.php');
    $nahme="OK1wqwtr1";
    $swl->assign('nameaa',$nahme);
    $swl->display("view.html");
?>

view.html
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>哈哈哈哈</title>
    <link rel="stylesheet" type="text/css" href="./public/haha.css">
</head>
<body>
    fd{:nameaa:}sf
</body>
</html>
index.php和one.php都可以成功解析模板变量显示正常,可是那个view.php总是出现下面的错误,是什么原因,view.php错误如下:?

Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "G:/WwwRoot/one/template\view.html" on line 9 "fd{:nameaa:}sf" unknown tag "nameaa"' in G:\WwwRoot\one\Library\smarty\sysplugins\smarty_internal_templatecompilerbase.php:439 Stack trace: #0 G:\WwwRoot\one\Library\smarty\sysplugins\smarty_internal_templatecompilerbase.php(261): Smarty_Internal_TemplateCompilerbase->trigger_template_error('unknown tag "na...', 9) #1 G:\WwwRoot\one\Library\smarty\sysplugins\smarty_internal_templateparser.php(2356): Smarty_Internal_TemplateCompilerbase->compileTag('nameaa', Array) #2 G:\WwwRoot\one\Library\smarty\sysplugins\smarty_internal_templateparser.php(2846): Smarty_Internal_Templateparser->yy_r38() #3 G:\WwwRoot\one\Library\smarty\sysplugins\smarty_internal_templateparser.php(2946): Smarty_Internal_Templateparser->yy_reduce(38) #4 G:\WwwRoot\one\Library\smarty\sysplugins\smarty_internal_smartytemplatecompiler.php(51): Smarty_Internal_Templat in G:\WwwRoot\one\Library\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 439
最佳答案
评论( 相关
后面还有条评论,点击查看>>