效果图:
是这篇《织梦文章页每个tag标签单独输出相关文章》的改进版,支持所有自定义字段输出
贴上调用实例代码:
<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,还需要开发下,可以参考《织梦dede:tag标签添加自增autoindex方法》
[field:id function='mbp_tag_description(@me)'/] 这些tagindex表里自定义字段的调用可以参考《织梦在extend.func.php里写函数实现任意地方调用任意模型的自定义字段》
织梦二次开发QQ群
本站客服QQ号:862782808(点击左边QQ号交流),群号(383578617) 如果您有任何织梦问题,请把问题发到群里,阁主将为您写解决教程!
转载请注明: 织梦模板 » 织梦文章页每个tag标签单独输出相关文章(支持自定义字段)