In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the "ThinkPHP tag production steps", in daily operation, I believe many people have doubts about the ThinkPHP tag production steps, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, I hope to answer the "ThinkPHP tag production steps" doubts helpful! Next, please follow the small series to learn together!
Here we add a label resolution to this class.
I. Label format:
Second, the role of labels:
Loop outputs columns whose parent id is parentid
III. Operation steps:
1. Add to the private properties of tagLibCx.class:
'category'=array('attr'=>'parentid',level=>3)
where attr: attribute level of tag Nested hierarchy of tag
2. Add an analytic function
The parsing principle of tags is to get the corresponding information by reading xml files, and then piece together the php source code needed, and finally output it on the page through echo.
The specific codes are as follows:
public function _category($attr,$content){//Parse all attributes of tag into $tag array $tag = $this->parseXmlAttr($attr,'category');//Get attributes in tag $parentid= $tag <$'parentid'];//Define variables for page parsing $result = ! empty($tag['result'])?$ tag <$'result ']:'cat'; //Defines the result storage variable $key = ! empty($tag['key'])?$ tag['key']:'i';$mod = isset($tag['mod'])?$ tag['mod']:'2';//Patch database query statements Here is a function wrapped directly in CategoryModel $sql = "D ('Category')->";$sql .= "getCategorys(".$ parentid. ')';//patchwork output characters $parsestr ='';$parsestr .= $content;//parse content in category tag $parsestr .= '';return $parsestr;}
getCategorys method in CategoryModel:
/** Get column information according to parentid * $parentid parent id* $withSelf whether contains itself */public function getCategorys ($parentid,$withSelf=0){$parentid=intval ($parentid);$categorys=$this->where (array('parentid'=>$parentid,'ismenu'=>1))->order ('listorder ASC')->select();//contains self if($withSelf){$categorys2=$this->where(array('id'=>$parentid,'ismenu'=>1))->limit(1)->select();$category=array_merge($categorys,$categorys2);}return $categorys;}
3. References on the page:
A label like that is done! We can get rid of that volist and dynamically output what we want on the page!
At this point, the study of "ThinkPHP tag production steps" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.