Home >php教程 >php手册 >thinkphp自定义闭合标签演示

thinkphp自定义闭合标签演示

WBOY
WBOYOriginal
2016-06-07 11:38:091311browse

thinkphp自定义闭合标签演示
模版文件最前面引入

你得自定义标签位置 这里我放在Admin模块下的TabLib下的文件夹下前端代码<br> <datagrid><br>     <a>{$title}</a><br>     </datagrid>后端代码<br> <?php <br /> namespace Admin\TagLib;<br> use Think\Template\TagLib;<br> <br> /**<br>  * EasyUI标签库<br>  */<br> class EasyUI extends TagLib{<br>     /*标签定义*/<br>     protected $tags = array(<br>         // 标签定义: attr 属性参数列表 close 是否闭合(0 或者 1 默认1) alias 标签别名容错性 level 嵌套层次<br>         'datagrid' => array('attr'=>'','close'=> 1)<br>     );<br> <br>     public function _datagrid($tag,$content){<br> <br>         $str = '<?php &#039;;<br />         $str .= '$data = array(array("title" => "新闻标题1"),array("title" => "新闻标题2"),array("title" => "新闻标题3"),array("title" => "新闻标题4"),array("title" => "新闻标题5"),array("title" => "新闻标题6"),array("title" => "新闻标题7"));';<br>         $str .= 'foreach($data as $row){';<br>         $str .= 'extract($row)';<br>         $str .= ' ?>';<br>         $str .= $this->tpl->parse($content);<br>         $str .= '<?php } ?>';<br>         return $str;<br>         //return "<h1>".$tag['content']."</h1>";<br>     }<br> }

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn