當前位置:首頁 » 編程語言 » php自定義標簽

php自定義標簽

發布時間: 2024-09-25 05:25:04

A. php 入口文件都配置好了的,但是用<a>跳轉後 action="<{spUrl c=main a=save}>" 就沒用起smarty,把路徑解

smarty模版變數沒法解析,不知道那些是變數?
應該這樣:在php文件里:
$smarty=new Smarty();
$smarty->Assign("spurl",$spurl);
...
...
$smarty->display("/main.html");
模版文件里這樣:
<a href="dest.php?action=<{$spurl}>&c=main&a=save">click here</a>

B. thinkphp3.2.3自定義標簽問題

需要自己先定義好,定義方法:

項目文件夾

新建一個文件,例如 Tp.class.php

<?php

namespaceThinkTemplateTagLib;

useThinkTemplateTagLib;

classTpextendsTagLib{

protected$tags=array(
'list'=>array('attr'=>'order,limit','close'=>1),
'webinfo'=>array('close'=>1),//1=<webinfo><webinfo/>
);

publicfunction_list($attr,$content){
$order=$attr['order'];//排序
$limit=$attr['limit'];//多少條數據

$str='<?php';
$str.='$result=M()->table(array("m_article"=>"article","m_menu"=>"menu","m_web_admin"=>"admin"))->field("article.*,menu.nameasmenu,admin.nameasauthor")->where("article.mid=menu.idandarticle.uid=admin.id")->order("'.$order.'")->limit('.$limit.')->select();';
$str.='foreach($resultas$v):';
$str.='?>';
$str.=$content;
$str.='<?phpendforeach?>';

return$str;
}

publicfunction_webinfo($attr='',$content){
$str='<?php';
$str.='$result=M("web_set")->where("id=1")->select();';
$str.='foreach($resultas$k=>$ii):';
$str.='?>';
$str.=$content;
$str.='<?phpendforeach?>';
return$str;
}}

兩個示例都是固定了數據表,可以根據自己的需要更改,或者直接做成變數,前台使用的時候再傳入。

第二步,在config文件中寫下如下代碼:

'TAGLIB_BUILD_IN' => 'Cx,Tp'


然後在模版中調用:

<!--webinfo使用方法-->
<webinfo>
<{$ii.web_name}>
</webinfo>

<!--list使用方法-->
<listlimit="10"order="iddesc">
<{$v.menu}>
</list>



M-finder博客:http://www.m-finder.com/,長期分享技術相關知識,歡迎大家訪問

C. phpcms怎樣使用自定義sql語句調用標簽

那叫 get ,在模板里可以用的.有教程,自己找.

熱點內容
曼特加編程 發布:2025-03-25 22:45:53 瀏覽:38
linux下ftp埠 發布:2025-03-25 22:40:52 瀏覽:138
淮陽壓縮模吧 發布:2025-03-25 22:40:02 瀏覽:118
查詢資料庫大小 發布:2025-03-25 22:31:56 瀏覽:645
2014加密相冊 發布:2025-03-25 22:23:59 瀏覽:569
怎麼查看汽車中控屏配置 發布:2025-03-25 22:23:16 瀏覽:568
安卓原生系統如何設置自動關機 發布:2025-03-25 21:45:34 瀏覽:384
壓縮復用代碼 發布:2025-03-25 21:27:24 瀏覽:625
控制台pycharm啟動腳本 發布:2025-03-25 21:19:20 瀏覽:819
天龍情緣腳本怎麼刷充值點 發布:2025-03-25 20:49:44 瀏覽:775