當前位置:首頁 » 編程語言 » 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 ,在模板里可以用的.有教程,自己找.

熱點內容
微信開發用什麼伺服器 發布:2024-09-25 07:18:32 瀏覽:364
手機伺服器網路是什麼意思 發布:2024-09-25 07:06:04 瀏覽:749
天音腳本 發布:2024-09-25 06:55:30 瀏覽:820
怎麼連接vps伺服器 發布:2024-09-25 06:55:19 瀏覽:217
win7裝linux系統 發布:2024-09-25 06:49:29 瀏覽:637
genericinjava 發布:2024-09-25 06:49:21 瀏覽:235
sql的執行步驟 發布:2024-09-25 06:43:47 瀏覽:131
手機照片存儲路徑 發布:2024-09-25 06:25:04 瀏覽:796
ftp數據怎麼導出 發布:2024-09-25 06:20:37 瀏覽:777
微信安卓手機從哪裡下載 發布:2024-09-25 06:02:09 瀏覽:21