|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
帝国CMS按分类输出所有TAG标签
本文关键字词:帝国CMS标签,TAG标签,TAGS
在网站根目录新建一个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 where classid!=0 order by classid asc");
- while ($tagclass_r = $empire->fetch($tagclass_sql)) {
- $tag_all = '';
- 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查询代码结束 -->
复制代码
以上只是实例代码。更多技巧请自行拓展。
附加例子(ECMS7.5以TAGID伪静态方式):
- <!-- 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 where classid!=0 order by classid asc");
- while ($tagclass_r = $empire->fetch($tagclass_sql)) {
- $tag_all = '';
- echo '<div class="tagbqn clearfix"><h3>' . $tagclass_r['classname'] . '</h3>' . PHP_EOL;
- /*按分类输出所有已分类TAG*/
- $tag_sql = $empire->query("select tagid,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-etagid' . $tag_r['tagid'] . '-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 tagid,tagname from {$dbtbpre}enewstags where cid=0 order by tagid desc");
- while ($tag_r = $empire->fetch($tag_sql)) {
- $tagslink = $public_r['newsurl'] . 'tags-etagid' . $tag_r['tagid'] . '-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查询代码结束 -->
复制代码
|
|