很多站长朋友们都不太清楚phpsmarty配置,今天小编就来给大家整理phpsmarty配置,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 php smarty前后台模板路径的配置问题 2、 php smarty 配置 3、 ThinkPHP3.2.3 配置smarty模板问题 4、 使用smarty需要修改php配置么 5、 thinkphp使用smarty模板后如何配置success和error跳转页面 php smarty前后台模板路径的配置问题$smarty=new
smarty;
$smarty->template_dir=base_path.smarty_path."templates/";
$smarty->compile_dir=base_path.smarty_path."templates_c/";
$smarty->config_dir=base_path.smarty_path."configs/";
$smarty->cache_dir=base_path.smarty_path."cache/";
//定义定界符
$smarty->left_delimiter='<{';
$smarty->right_delimiter="}>";
$smarty2
=
new
smarty;
$smarty->template_dir=front_path.smarty_path."templates/";
$smarty->compile_dir=front_path.smarty_path."templates_c/";
$smarty->config_dir=front_path.smarty_path."configs/";
$smarty->cache_dir=front_path.smarty_path."cache/";
//定义定界符
$smarty->left_delimiter='<{';
$smarty->right_delimiter="}>";
不一定几套,
你想弄几套都行,你只要为你实例化的smarty对象做相应的设置就行啦。
php smarty 配置我在本地测试过了,没问题的,我的发布目录为d:/www/del_smarty/
目录结构:d:/www/del_smarty/
/libs(里面包含smarty)
/templates
/templates_c
/cache
/configs
-----------------------------------------------------------------
main.php
<?php
define("SMARTY_PATH","d:/www/del_smarty/");
require_once("libs/Smarty.class.php");
$tpl = new Smarty;
/**
* 我的路径指向方式
$tpl -> template_dir = SMARTY_PATH.'templates/';
$tpl -> compile_dir = SMARTY_PATH.'templates_c/';
$tpl -> cache_dir = SMARTY_PATH.'cache/';
$tpl -> config_dir = SMARTY_PATH.'configs/';
**/
$tpl -> template_dir = 'd:/www/del_smarty/templates/';
$tpl -> compile_dir = 'd:/www/del_smarty/templates_c/';
$tpl -> cache_dir = 'd:/www/del_smarty/cache/';
$tpl -> config_dir = 'd:/www/del_smarty/configs/';
$tpl -> left_delimiter = '<{';
$tpl -> right_delimiter = '}>';
?>
---------------------------------------------------
test.php
<?php
require_once("main.php");
$tpl -> assign('title','test title');
$tpl -> assign('content','test content');
$tpl -> display('test.htm');
?>
-------------------------------------------------------
test.htm
<html>
<><br/>
<>
</html>
这个应该是php的语法错误提示,你再看看你的错误那行的标点没有在中文状态下吧?不行就Q我吧,33712313
我最近也在研究smarty,呵呵,共同研究嘛
ThinkPHP3.2.3 配置smarty模板问题修改配置文件 ThinkPHP\Conf\convention.php
{XT:} {/XT}可根据个人喜好自定义
修改1:
// 布局设置
'TMPL_ENGINE_TYPE' => 'Smarty', // 默认模板引擎 以下设置仅对使用Think模板引擎有效
'TMPL_CACHFILE_SUFFIX' => '.html', // 默认模板缓存后缀
'TMPL_DENY_FUNC_LIST' => 'echo,exit', // 模板引擎禁用函数
'TMPL_DENY_PHP' => false, // 默认模板引擎是否禁用PHP原生代码
'TMPL_L_DELIM' => '{XT:}', // 模板引擎普通标签开始标记
'TMPL_R_DELIM' => '{/XT}', // 模板引擎普通标签结束标记
修改2:
增加
//Smarty 模版引擎配置
'TMPL_ENGINE_CONFIG' => array(
'debugging'=>false,
//'error_reporting'=>'',
//'exception_handler'=>array('ExceptionClass','ExceptionMethod'),
//'template_dir' => TMPL_PATH, //模板目录
//'compile_dir' =>TEMP_PATH ,//编译目录
//'cache_dir' =>CACHE_PATH, //缓存目录
'caching' => false, //是否启用缓存
'cache_lifetime' =>1,//缓存时间s
'left_delimiter'=>'{XT:}',
'right_delimiter' =>'{/XT}',
),
使用smarty需要修改php配置么使用smarty不需要修改php配置,一般只需要将下载的源代码文件放置于网站目录下,然后再使用时,用require/include引入即可。
示例代码:
require 'smarty/libs/Smarty.class.php';
thinkphp使用smarty模板后如何配置success和error跳转页面//可以在config配置文件里面自定义success和error的提示页面模板的位置
'TMPL_ACTION_SUCCESS'=>'Public:dispatch_jump',
‘TMPL_ACTION_ERROR'=>'Public:dispatch_jump',
但是会存在一个问题,smarty模板引擎是无法解析这个跳转页面的!
关于phpsmarty配置的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于phpsmarty配置 phpstudy 配置的详细内容...