/*********************************************
*
* 文件名: example6.php
* 作 用: 显示实例程序2
*
* 作 者: Eddy
* Email: liabc4325@163.com
*
*********************************************/
/* Smarty要求4个目录,默认下命名为:tempalates, templates_c, configs and cache。每个都是可以自定义的,可以修改Smarty类属性: $ template_dir, $ compile_dir, $ config_dir, and $ cache_dir respectively。强烈推荐你为每个用到smarty的应用程序设置单一的目录! */
// Edit your php.ini file, add the Smarty library
// directory to the include_path and restart web server.
// Then the following should work:
include_once("Smarty.class.php");
$ smarty = new Smarty();
$ smarty->template_dir=("../smarty/templates/");
$ smarty->compile_dir=("../smarty/templates_c/");
$ smarty->configs_dir=("../smarty/configs/");
$ smarty->cache_dir=("../smarty/cache/");
$ smarty->cache_lifetime = 0;
$ smarty->caching = true;
$ smarty->left_delimiter = "{";
$ smarty->right_delimiter = "}";
$ array[] = array("newsID"=>1, "newsTitle"=>"第1条新闻");
$ array[] = array("newsID"=>2, "newsTitle"=>"第2条新闻");
$ array[] = array("newsID"=>3, "newsTitle"=>"第3条新闻");
$ array[] = array("newsID"=>4, "newsTitle"=>"第4条新闻");
$ array[] = array("newsID"=>5, "newsTitle"=>"第5条新闻");
$ array[] = array("newsID"=>6, "newsTitle"=>"第6条新闻");
$ smarty->assign("newsArray", $ array);
//编译并显示位于./templates下的index.tpl模板
$ smarty->display("example6.tpl");
?>
*
* 文件名: example6.php
* 作 用: 显示实例程序2
*
* 作 者: Eddy
* Email: liabc4325@163.com
*
*********************************************/
/* Smarty要求4个目录,默认下命名为:tempalates, templates_c, configs and cache。每个都是可以自定义的,可以修改Smarty类属性: $ template_dir, $ compile_dir, $ config_dir, and $ cache_dir respectively。强烈推荐你为每个用到smarty的应用程序设置单一的目录! */
// Edit your php.ini file, add the Smarty library
// directory to the include_path and restart web server.
// Then the following should work:
include_once("Smarty.class.php");
$ smarty = new Smarty();
$ smarty->template_dir=("../smarty/templates/");
$ smarty->compile_dir=("../smarty/templates_c/");
$ smarty->configs_dir=("../smarty/configs/");
$ smarty->cache_dir=("../smarty/cache/");
$ smarty->cache_lifetime = 0;
$ smarty->caching = true;
$ smarty->left_delimiter = "{";
$ smarty->right_delimiter = "}";
$ array[] = array("newsID"=>1, "newsTitle"=>"第1条新闻");
$ array[] = array("newsID"=>2, "newsTitle"=>"第2条新闻");
$ array[] = array("newsID"=>3, "newsTitle"=>"第3条新闻");
$ array[] = array("newsID"=>4, "newsTitle"=>"第4条新闻");
$ array[] = array("newsID"=>5, "newsTitle"=>"第5条新闻");
$ array[] = array("newsID"=>6, "newsTitle"=>"第6条新闻");
$ smarty->assign("newsArray", $ array);
//编译并显示位于./templates下的index.tpl模板
$ smarty->display("example6.tpl");
?>
Comments
Post a Comment