织梦tag标签首页分页实现效果图:

可以新建标签栏目作为tag首页:
![]()
分页是参考这个教程来实现的:《》
tagindex.htm模板里的代码这样写:
{dede:listsql sql="select * from dede_tagindex" pagesize="10"}
<li>
<a href="[field:id function='mbp_tag_url(@me)'/]">
<img src="[field:tagimg/]" alt="[field:tag /]">
<span>[field:tag /]</span>
</a>
</li>
{/dede:listsql}
<div class="pages"><p class="clearfix">
{dede:pagelist listitem="end,pre,next,pageno,info" listsize="4"/}
</p></div>[field:tag /]是tag标签名称,[field:tagimg/]是tag标签缩略图,分页样式在include/arc.listview.class.php这个文件里修改。
[field:id function='mbp_tag_url(@me)'/]这个是一个写在/include/extend.func.php里的函数,是调用tag标签的列表页地址
在/include/extend.func.php文件最后面写入这样的代码:
//获取TAG静态地址
function mbp_tag_url($tid)
{
global $dsql;
$sql = "select * from `dede_tagindex` where id='$tid' ";
$str = '';
if ($arcRow = $dsql->GetOne($sql)){
$arcRow['tagdir'] = trim($arcRow['tagdir']);
$arcRow['id'] = intval($arcRow['id']);
$tag_basedir = trim($GLOBALS['cfg_tag_basedir'],'/ ');
$tag_basedir = empty($tag_basedir) ? 'tag' : $tag_basedir;
$tag_style = isset($GLOBALS['cfg_tag_style']) ? intval($GLOBALS['cfg_tag_style']) : 1;
if ($tag_style < 1 || $tag_style > 4) $tag_style = 1;
//1:拼音目录
if ($tag_style == 1) {
$str = $GLOBALS['cfg_cmspath'].'/'.$tag_basedir.'/'.$arcRow['tagdir'].'/';
}
//2:ID目录
if ($tag_style == 2) {
$str = $GLOBALS['cfg_cmspath'].'/'.$tag_basedir.'/'.$arcRow['id'].'/';
}
//3:拼音url 如:tag/baicai.html(白菜) tag/baicai3.html(百菜)
if ($tag_style == 3) {
if ($arcRow['tagdir'] == 'index') $arcRow['tagdir'].= $arcRow['id'];
$str = $GLOBALS['cfg_cmspath'].'/'.$tag_basedir.'/'.$arcRow['tagdir'].'.html';
}
//4:ID url 如:tag/1.html
if ($tag_style == 4) {
$str = $GLOBALS['cfg_cmspath'].'/'.$tag_basedir.'/'.$arcRow['id'].'.html';
}
}else $str="ID为$tid的TAG已被删除!";
return $str;
}
//获取指定文章的TAG到相关TAG列表页的地址
// $html=<a href="{url}">{tag}</a> 自动替换为 $html=<a href="/tag/ceshi/">测试</a>
function mbp_arc_tag_link($aid, $html='')
{
global $dsql;
$sql = "select tid from `dede_taglist` where aid='$aid' group by tid ";
$dsql->Execute('ala',$sql);
while($row=$dsql->GetObject('ala')){
$url=mbp_tag_url($row->tid);
if ($arcRow = $dsql->GetOne("select * from `dede_tagindex` where id='".$row->tid."' ")) $tag=$arcRow["tag"];
else $tag="";
//$str .= "<a href='{$url}' target='_blank'>{$tag}</a>"
$html = trim($html);
if (empty($html)) {
$str.=" <a href='".$url."' target=_blank>".$tag."</a> "; //在这里修改链接样式:$url 为链接 $tag为标签名称
} else {
$html = str_replace('{url}',$url,$html);
$html = str_replace('{tag}',$url,$html);
$str .= $html;
}
}
return $str;
}此教程是《》这个教程的拓展。
版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!
转载请注明: 织梦tag标签首页分页(支持手机tag)实现方法