帝国CMS按分类输出所有TAG标签,具体操作如下:在网站根目录新建一个tag.php文件,加入以下代码即可(样式自行修改)
tag.php Code:
<!-- TAG查询代码开始 --> <?php require('./e/class/connect.php'); //引入数据库配置文件和公共函数文件 require('./e/class/db_sql.php'); //引入数据库操作文件 require('./e/data/dbcache/class.php'); //引入栏目缓存文件 $link=db_connect(); //连接MYSQL $empire=new mysqlquery(); //声明数据库操作类 //获得TAG分类 $tagclass_sql=$empire->query('select classid,classname from '.$dbtbpre.'enewstagsclass order by classid asc'); while($tagclass_r=$empire->fetch($tagclass_sql)){ echo '<div class="tagbqn clearfix"><h3>'.$tagclass_r['classname'].'</h3>'.PHP_EOL; /*按分类输出所有已分类TAG*/ $tag_sql=$empire->query('select tagname from '.$dbtbpre.'enewstags where cid='.$tagclass_r['classid'].' order by tagid desc'); while($tag_r=$empire->fetch($tag_sql)){ $tagslink=$public_r['newsurl'].'tags-'.urlencode($tag_r['tagname']).'-0.html';//TAG标签链接 $tag_all.='<a href="'.$tagslink.'" title="'.$tag_r['tagname'].'">'.$tag_r['tagname'].'</a>'; } echo $tag_all.PHP_EOL.'</div>'.PHP_EOL; } /*其他TAG标签*/ echo '<div class="tagbqn clearfix"><h3>未分类标签</h3>'.PHP_EOL; /*按分类输出所有TAG*/ $tag_sql=$empire->query('select tagname from '.$dbtbpre.'enewstags where cid=0 order by tagid desc'); while($tag_r=$empire->fetch($tag_sql)){ $tagslink=$public_r['newsurl'].'tags-'.urlencode($tag_r['tagname']).'-0.html';//TAG标签链接 $tag_other.='<a href="'.$tagslink.'" title="'.$tag_r['tagname'].'">'.$tag_r['tagname'].'</a>'; } echo $tag_other.PHP_EOL.'</div>'.PHP_EOL; db_close(); //关闭MYSQL链接 $empire=null; //注消操作类变量 ?> <!-- TAG查询代码结束 -->
以上只是实例代码。更多技巧请自行拓展。