The use of template tags can make the site foreground development faster and simpler, the use of Dedecms, PHPCMS and other content management systems should be aware that the CMS front desk is to use template tags to invoke data. To invoke the list of articles as an example:
Dedecms can be written as:
{dede:arclist row= ' orderby= ' id desc ' titlelen= '}
- [Field:title]
{/dede:arclist}
Phpcms can be written as:
{pc:content action= "hits" catid= "6" num= "ten" order= "Views DESC"} {Loop $data $r}
- {$r [title]}
{/loop} {/PC}
Thinkphp's custom tags also enable such a powerful feature. Thinkphp custom tags are implemented through the tag extension library. and thinkphp itself with a tag extension library as long as we inherit taglib will be able to meet the definition of their own label.
Naming conventions:
taglib+ Tag Library name. class.php
The following is an example of implementing call navigation as an illustration
The file TagLibNav.class.php is as follows:
<?phpclass Taglibnav extends TagLib { //attr attribute list //close closed (0 or 1 default 1) //alias tag alias //level nesting level The c4/>//tag is defined as follows: protected $tags = Array (' nav ' = = Array (' attr ' = ' limit,order ', ' level ' = + 3, ' close ' => ; 1), ); Define Query Database label //attr is a list of attributes, $content is the public function _nav ($attr, $content) that stores the contents between tags { $tag = $this Parsexmlattr ($attr, $content); $cate =m (' Channel '); $TB = $cate->order ($tag [' Order '])->limit ($tag [' limit '])->select (); $str = "; for ($i =0; $i
How HTML pages are called:
Tablist
Configuration file:
' App_autoload_path ' = ' @ '. TagLib ', //taglib's position @. Indicates the current folder under ' taglib_build_in ' = ' cx,nav ', // CX is the name of the Thinkphp base Class library that must be referenced otherwise volist such as labels cannot be used, NAV is its own defined label name
Controller:
<?phpclass Indexaction extends action{public function Index () { $this->display ();} }? >
The custom label has been implemented so that there is no need to write much code in the controller.
http://www.bkjia.com/PHPjc/824769.html www.bkjia.com true http://www.bkjia.com/PHPjc/824769.html techarticle The use of template tags can make the site foreground development faster and simpler, the use of Dedecms, PHPCMS and other content management system should be aware that the CMS front desk is to use template tags to call ...