thinkphp steps to use the tag library

Source: Internet
Author: User
Application Example: In the business center of the management of supply and demand Information page: using the tag library to generate a list;

Step One:
Under the project configuration file conf folder, create a new taglibs.php file that will
Return Array (
' html ' = ' @ '. Taglib.taglibhtml ',//path format supported using the Import method
);
Copy it, which is the definition of which tag library to use in this project;

Step Two:
In the Lib directory, create a new TagLib folder;
Lib/taglib/tags/html.xml the definition file of the tag library;
Lib/taglib/taglibhtml.class.php the parsing class of tag library;

Step Three:
Copy the CommonAction.class.php in the action directory;
Copy the CommonModel.class.php in the model directory;

Step Four:
Lib/action directory; Create a new class: for example: ProductsAction.class.php

Class Productsaction extends Commonaction {
}
If written as:
Class FormAction extends Commonaction {
Filter query fields
Function _filter (& $map) {
$map [' title '] = Array (' Like ', "%". $_post[' name '). " %");
}
}
The _filter function is used to pass query conditions;

This place needs to be noted: products must be the table name of the corresponding database;


Step Five:
Create a new products folder in the template;
Index.html needs to be included;

The basic JS file;
<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" >
<!--
Specifies the current group module URL address
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>

Load Tag Library:
<taglib name= "html"/>

<!--list display area--
<div >
</div>
<!--page display area--
<div class= "page" >{$page}</div>
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.