亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

smarty模板解壓完將libs目錄放到哪?

smarty模板解壓完將libs目錄放到哪?

小怪獸愛吃肉 2019-02-25 10:06:41
smarty模板解壓完將libs目錄放到哪
查看完整描述

4 回答

?
一只斗牛犬

TA貢獻1784條經驗 獲得超2個贊

1.寫一個模板文件(tpl),通常放在templates
2.在php文件中引入smarty的核心文件,并創建smarty對象:
1 //創建smarty對象
require_once './libs/Smarty.class.php';
3 $smarty = new Smarty;//建立smarty實例對象$smarty
把數據分配給smarty對象,給tpl文件分配要顯示的結果集合。對象,數組。
1 //把$res分配到smarty對象
2 $smarty->assign("myArr",$arr);
3 //指定用哪個模版顯示
4 $smarty->display("empList2.tpl");

初始化其他參數(這些初始化應該放在display函數上面)

1 $smarty -> caching = false;//是否使用緩存
2 $smarty -> template_dir = "./templates";//設置模板目錄
3 $smarty -> compile_dir = "./templates_c";//設置編譯目錄
4 $smarty -> cache_dir = "./smarty_cache";//緩存文件夾
5 //修改左右邊界符號
6 $smarty -> left_delimiter="<{";
7 $smarty -> right_delimiter="}>";



查看完整回答
反對 回復 2019-03-30
?
慕碼人2483693

TA貢獻1860條經驗 獲得超9個贊

smarty安裝網站根目錄下或者其他目錄都可以,只要路徑配置對了,就可以正常訪問。
安裝方法如下
第一部分:文件夾配置
第一步:解壓得到的文件夾命名為smarty
第二步:在smarty里面新建一個mysmarty文件夾。
第三步將smarty里面的libs文件夾里面的文件全部移動到mysmarty文件夾中。
第四步:在mysmarty文件夾里新建config,templates,smarty_templates_c,smarty_cache文件夾。

第二部分:單頁文件
第五步:在mysmarty文件夾下新建index.php
第六步:在mysmarty文件夾下的template文件夾下新建index.tpl

——————index.php代碼為
<?php
//載入Smarty庫
include("Smarty.class.php");

$smarty = new Smarty;

//下面的(你的網站目錄)用絕對路徑,比如d:/intepub/wwwroot
$smarty->template_dir = 'E:/APMServ/smarty/mysmarty/templates';
$smarty->config_dir = 'E:/APMServ/smarty/mysmarty/config';
$smarty->cache_dir = 'E:/APMServ/smarty/mysmarty/smarty_cache';
$smarty->compile_dir = 'E:/APMServ/smarty/mysmarty/smarty_templates_c';
//上面四行為使用Smarty前的必要參數配置

$smarty->assign('name','這是第一個smarty!');
$smarty->display('templates/index.tpl');
?>

——————————————index.tpl代碼為
<html>
<body>
你好,{$name}
</body>
</html>
第三步分:測試
第七步:運行index.php
運行結果
你好,這是第一個smarty!



查看完整回答
反對 回復 2019-03-30
?
喵喔喔

TA貢獻1735條經驗 獲得超5個贊

define(PATH,$_SERVER['DOCUMENT_ROOT']."/");
include_once(PATH."libs/Smarty.class.php");//引用類文件
$tpl=new Smarty;//創建對象
//設置基本配置信息
$tpl->template_dir=PATH."templates";//模板目錄
$tpl->compile_dir=PATH."templates_c";//編譯目錄
$tpl->config_dir=PATH."config";//配置目錄
$tpl->cache_dir=PATH."cache";//緩存目錄
$tpl->display("admin/b.htm");



查看完整回答
反對 回復 2019-03-30
  • 4 回答
  • 0 關注
  • 478 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號