关于smarty模板文件(左边界,右边界)

来源:互联网 发布:淘宝大连博哲贸易怎样 编辑:程序博客网 时间:2024/05/16 16:16

前言
Smarty是一个使用PHP写出来的模板引擎,是目前业界最著名的PHP模板引擎之一。它分离了逻辑代码和外在的内容,提供了一种易于管理和使用的方法,用来将原本与HTML代码混杂在一起PHP代码逻辑分离。简单的讲,目的就是要使PHP程序员同前端人员分离,使程序员改变程序的逻辑内容不会影响到前端人员的页面设计,前端人员重新修改页面不会影响到程序的程序逻辑,这在多人合作的项目中显的尤为重要。

<?phprequire_once(_ROOT."include/smarty/libs/Smarty.class.php");    //这里一定要导入库    class ViewTemplates extends Smarty    {        function  ViewTemplates()        {            global $module;            $this->Smarty();            $this->template_dir = ORGTOOLS."view/templates/$module";            $this->compile_dir  = ORGTOOLS."view/templates_c/$module";            $this->cache_dir    = ORGTOOLS."view/cache/$module";            //上面三个文件一定要存在,不然无法使用            $this->caching = false;            $this->cache_lifetime = 60*30;//30 min            $this->compile_check = true;            $this->debugging = false;            $this->left_delimiter = "{/";            $this->right_delimiter = "/}";            //这里定义了左边界,右边界,也就是html或者php或者tpl一定要以{/  /}这种格式写后台传过去的参数,不然,前端识别不了             $this->assign(array("cookiedomain"=>COOKIE_DOMAIN));            $this->assign("SERVER", SERVER_ADDRESS);            define("SERVER_TOOlS", SERVER_ADDRESS."tools/");        }    }?>
1 0
原创粉丝点击