效果图:
是这篇《》的改进版,支持所有自定义字段输出
贴上调用实例代码:
<div class="guess"> <h3>猜你喜欢</h3> <ol class="clearfix"> {dede:tag row='4' sort='new' getall='0'} <li [field:array runphp=yes] ($GLOBALS[autoindex]==1) ? @me="class='on'":@me="";[/field:array]>[field:tag /]</li> {/dede:tag} </ol> {dede:tag row='4' sort='new' getall='0'} <ul class="clearfix" [field:array runphp=yes] ($GLOBALS[autoindex]==1) ? @me="style='display: block'":@me="style='display:none'";[/field:array]> <li class='first'> <a class='pic' href='[field:global.cfg_basehost/][field:id function='mbp_tag_url(@me)'/]'><img src='[field:global.cfg_basehost/][field:id function='mbp_tag_img(@me)'/]' alt='[field:tag /]'></a> <h5><a href='[field:global.cfg_basehost/][field:id function='mbp_tag_url(@me)'/]' title='[field:tag /]'>[field:tag /]</a></h5> <p>[field:id function='mbp_tag_description(@me)'/]</p> </li> [field:tag runphp=yes] global $dsql,$id,$aid; $myid = isset($id) ? $id : $aid; $taga = @me; $arow = $dsql->GetOne("Select * From `dede_tagindex` where tag like '$taga'"); $tid = $arow['id']; if($tid!='') { $tagsql = "Select aid From `dede_taglist` where tid = $tid And arcrank > -1 group by aid order by aid desc"; $dsql->SetQuery($tagsql); $dsql->Execute('t'); $result = ''; while($arow = $dsql->GetArray('t')) { $ids[] = $arow['aid']; } } if(count($ids) > 0) { $idsStr = join(',', $ids); $query = "Select arc.*,addf.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath from `dede_archives` arc left join `dede_arctype` tp on arc.typeid=tp.id left join dede_addonarticle addf on arc.id = addf.aid where arc.arcrank>-1 and arc.id in($idsStr) And arc.id<>$myid order by arc.id desc limit 9";//输入多少个文章 } $dsql->SetQuery($query); $dsql->Execute('t'); $result = ''; $totalRow = $dsql->GetTotalRow(); while($row = $dsql->GetArray('t')) { global $cfg_basehost; $arcurl = GetOneArchive($row['id']); $result .= "<li><a class='pic' href='$cfg_basehost{$arcurl['arcurl']}'><img src='$cfg_basehost{$row['litpic']}' alt='{$row['title']}'></a> <h5><a href='$cfg_basehost{$arcurl['arcurl']}' title='{$row['title']}'>{$row['title']}</a></h5> <p>作者:{$row['zuozhe']}</p> <p><em>{$row['typename']}</em></p> </li>"; } if($result=='') $result = "<p style='color:#f00;'>该TAG标签没有相关文章</p>"; @me = $result; [/field:tag] </ul> {/dede:tag} </div>
要让tag标签支持自增函数autoindex,还需要开发下,可以参考《》
[field:id function='mbp_tag_description(@me)'/] 这些tagindex表里自定义字段的调用可以参考《》
版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!