+ -
当前位置:首页 → 问答吧 → 初识Smarty模板的小问题

初识Smarty模板的小问题

时间:2011-10-19

来源:互联网

刚下的smarty3,按照说明稍微部署了下,运行里边儿的测试页面 index.php(http://localhost/Smarty/demo/index.php)一切正常。
参照某个教程自己做了一个页面出现问题了: 打开http://localhost/Smarty/demo/test.php 里面全是空白。
samrty放置路径:F:\work\PhonesCalls\Smarty;


main.php (F:\work\PhonesCalls\Smarty\libs\main.php):
PHP code

  <?php
  include "libs/Smarty.class.php";
  define('__SITE_ROOT', 'F:/work/PhonesCalls/Smarty/demo'); 
  $tpl = new Smarty();
  $tpl->template_dir = __SITE_ROOT . "/templates/";
  $tpl->compile_dir = __SITE_ROOT . "/templates_c/";
  $tpl->config_dir = __SITE_ROOT . "/configs/";
  $tpl->cache_dir = __SITE_ROOT . "/cache/";
  $tpl->left_delimiter = '<{';
  $tpl->right_delimiter = '}>';
  ?>




test.php (F:\work\PhonesCalls\Smarty\demo\test.php)
PHP code

  <?php
  require "main.php";
  $tpl->assign("title", "测试用的网页标题");
  $tpl->assign("content", "测试用的网页内容");
  $tpl->display('test.html');
  ?>



test.html (F:\work\PhonesCalls\Smarty\demo\templates\test.html)
PHP code

 <html>
  <head>
  <meta http-equiv="Content-Type" c>
  <title><{$title}></title>
     </head>
  <body>
  <{$content}>
  </body>
  </html>



找了半天还是没发现是逻辑上面的问题还是代码的问题

作者: johnsneaker   发布时间: 2011-10-19

main.php你Require进去了否?

作者: ZT_King   发布时间: 2011-10-19

拷贝你index.php的配置试下

作者: heyli   发布时间: 2011-10-19