thinkphp 使用標籤庫的步驟

來源:互聯網
上載者:User
應用執行個體:在 商務中心的 管理供求資訊 頁面:利用標籤庫產生列表;

步驟一:
在項目設定檔Conf檔案夾下,建立一個taglibs.php檔案,將
return array(
'html'=> '@.TagLib.TagLibHtml' , // 使用import方法支援的路徑格式
);
拷貝進去,這是定義本項目使用哪個標籤庫;

步驟二:
在Lib目錄下,建立 TagLib 檔案夾;
Lib/TagLib/Tags/html.xml 標籤庫的定義檔案;
Lib/TagLib/TagLibHtml.class.php 標籤庫的解析類;

步驟三:
拷貝 CommonAction.class.php 在Action 目錄下;
拷貝 CommonModel.class.php 在Model 目錄下;

步驟四:
lib/Action目錄下;建立一個類:例如:ProductsAction.class.php

class ProductsAction extends CommonAction {
}
如果寫成:
class FormAction extends CommonAction {
//過濾查詢欄位
function _filter(&$map){
$map['title'] = array('like',"%".$_POST['name']."%");
}
}
_filter函數是用來傳遞查詢條件的;

這個地方需要注意:Products必須是對應的資料庫的表名;


步驟五:
在模板中建立一個 Products檔案夾;
index.html 需要包含;

基本的JS檔案;
<load href="__PUBLIC__/Js/Base.js" />
<load href="__PUBLIC__/Js/prototype.js" />
<load href="__PUBLIC__/Js/mootools.js" />
<load href="__PUBLIC__/Js/Ajax/ThinkAjax.js" />
<load href="__PUBLIC__/Js/common.js" />
<load href="__PUBLIC__/Js/Util/ImageLoader.js" />
<script language="JavaScript">
<!--
//指定當前組模組URL地址
var URL = '__URL__';
var APP = '__APP__';
var PUBLIC = '__PUBLIC__';
ThinkAjax.image = [ '__PUBLIC__/images/loading2.gif', '__PUBLIC__/images/ok.gif','__PUBLIC__/images/update.gif' ]
ImageLoader.add("__PUBLIC__/images/bgline.gif","__PUBLIC__/images/bgcolor.gif","__PUBLIC__/images/titlebg.gif");
ImageLoader.startLoad();
//-->
</script>

載入標籤庫:
<tagLib name="html" />

<!-- 列表顯示地區 -->
<div >
<html:list id="checkList" style="list" checkbox="true" action="true" datasource="list" show="id:編號|8%,name:資訊標題:edit,upload_time|toDate='y-m-d':發布日期,checkstatus|getStatus:審核是否通過" actionlist="foreverdel:刪除:id,edit:編輯:id" />
</div>
<!-- 分頁顯示地區 -->
<div class="page">{$page}</div>
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.