ThinkPHP的标签制作,ThinkPHP标签制作
ThinkPHP的标签制作,ThinkPHP标签制作
thinkphp的默认标签解析器在Lib/Template/TagLib/TagLibCx.class中 里面定义了常用的volist php 等常用thinkphp的标签 这里笔者在这个类中添加一个<br />public function _category($attr,$content)<br />{<br />//把标签的所有属性解析到$tag数组里面<br />$tag = $this->parseXmlAttr($attr,'category');<br /> <br />//得到标签里面的属性<br />$parentid= $tag['parentid'];<br /> <br />//定义页面解析的变量<br />$result = !empty($tag['result'])?$tag['result']:'cat'; //定义数据查询的结果存放变量<br />$key = !empty($tag['key'])?$tag['key']:'i';<br />$mod = isset($tag['mod'])?$tag['mod']:'2';<br /> <br />//拼凑数据库查询语句 这里直接用了CategoryModel封装好的函数<br />$sql = "D('Category')->";<br />$sql .= "getCategorys(".$parentid.')';<br /> <br />//拼凑输出字符<br />$parsestr = '<?php $_result='.$sql.'; if ($_result): $'.$key.'=0;';<br />$parsestr .= 'foreach($_result as $key=>$'.$result.'):';<br />$parsestr .= '++$'.$key.';$mod = ($'.$key.' % '.$mod.' );?>';<br />$parsestr .= $content;//解析在category标签中的内容<br />$parsestr .= '<?php endforeach; endif;?>';<br />return $parsestr;<br /> <br />}<br /> <br />CategoryModel中的getCategorys方法<br />/*<br />* 根据parentid得到栏目信息<br />* $parentid 父id<br />* $withSelf 是否包含自己<br />*/<br /> <br />public function getCategorys($parentid,$withSelf=0)<br />{<br />$parentid=intval($parentid);<br />$categorys=$this->where(array('parentid'=>$parentid,'ismenu'=>1))->order('listorder ASC')->select();<br />//包含自己<br />if($withSelf)<br />{<br />$categorys2=$this->where(array('id'=>$parentid,'ismenu'=>1))->limit(1)->select();<br />$category=array_merge($categorys,$categorys2);<br />}<br />return $categorys;<br /> <br />}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

1. Start PPT, create a new blank document, select all text boxes and delete them. 2. Execute the Insert-Shape command, drag a rectangle in the document, and fill the shape with black. 3. Drag the rectangle to elongate it, execute the Insert-Shape command, drag out the small square, and set the fill color to white. 4. Copy and paste the small squares one by one so that the top and bottom are evenly distributed on both sides of the film. After selecting them all with ctrl+a, right-click and select Group. 5. Execute the Insert-Picture command, find the picture to be inserted in the pop-up dialog box, click to open, and adjust the size and position of the picture. 6. Repeat step 5 to insert and set the remaining pictures in order to form a film picture. 7. Select the film, execute animation-add animation command

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

Analysis of new features of Win11: How to skip logging in to a Microsoft account. With the release of Windows 11, many users have found that it brings more convenience and new features. However, some users may not like having their system tied to a Microsoft account and wish to skip this step. This article will introduce some methods to help users skip logging in to a Microsoft account in Windows 11 and achieve a more private and autonomous experience. First, let’s understand why some users are reluctant to log in to their Microsoft account. On the one hand, some users worry that they

[Analysis of the meaning and usage of midpoint in PHP] In PHP, midpoint (.) is a commonly used operator used to connect two strings or properties or methods of objects. In this article, we’ll take a deep dive into the meaning and usage of midpoints in PHP, illustrating them with concrete code examples. 1. Connect string midpoint operator. The most common usage in PHP is to connect two strings. By placing . between two strings, you can splice them together to form a new string. $string1=&qu
