自定义标签的笔记,下面是一个简单的标签flink,解释一下:
<?php<BR>//检查是否定义include文件夹的路径DEDEINC<BR> if(!defined('DEDEINC')) { exit("Request Error!"); } //写标签时,默认调用的方法 function lib_flink(&$ctag,&$refObj) {<BR> //声明全局的数据库连接<BR> global $dsql;<BR> //标签拥有的属性和默认值<BR> $attlist="type|textall,row|24,titlelen|24,linktype|1,typeid|0"; FillAttsDefault($ctag->CAttribute->Items,$attlist);<BR> //将标签中的值导入到当前符号表中<BR> extract($ctag->CAttribute->Items, EXTR_SKIP); $totalrow = $row; $revalue = ''; //以下为拼装SQL查询语句 $wsql = " where ischeck >= '$linktype' "; if($typeid == 0) { $wsql .= ''; } else { $wsql .= "And typeid = '$typeid'"; } if($type=='image') { $wsql .= " And logo<>'' "; } else if($type=='text') { $wsql .= " And logo='' "; } $equery = "Select * from dede_flink $wsql order by sortrank asc limit 0,$totalrow"; //检查标记中是否已经包含innertext底层 if(trim($ctag->GetInnerText())=='') $innertext = "<li>[field:link /]</li>";