导航首页 » 网站优化

织梦调用当前文章tag标签对应的文章列表方法

2023/03/11 12:23    魔司收录网    已浏览145次

织梦调用当前文章tag标签对应的文章列表方法,看效果图:

织梦调用当前文章tag标签对应的文章列表方法


调用代码:
 

01 {dede:tag row='30' sort='new' getall='0'}
02 <div class="hot mt1">
03 <dl class="tbox light">
04 <dt class='light'><strong>[field:tag /]</strong></dt>
05 <dd class='light'>
06 <ul class="c1 ico2">
07 [field:tag runphp=yes]
08 global $dsql,$aid;
09 $i = 1;
10 $taga = @me;
11 $arow = $dsql->GetOne("Select * From `dede_tagindex` where tag like '$taga'");
12 $tid = $arow['id'];
13 if($tid!='')
14 {
15 $tagsql = "Select aid From `dede_taglist` where tid = $tid And arcrank > -1 group by aid order by aid desc";
16 $dsql->SetQuery($tagsql);
17 $dsql->Execute('t');
18 $result = '';
19 while($arow = $dsql->GetArray('t'))
20 {
21 $ids[] = $arow['aid'];
22 }
23 }
24 if(count($ids) > 0)
25 {
26 $idsStr = join(',', $ids);
27   
28 $query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,
29   
30 tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
31   
32 from `dede_archives` arc left join `dede_arctype` tp on arc.typeid=tp.id
33   
34 where arc.arcrank>-1 and arc.id in($idsStr) And arc.id<>$aid order by arc.id desc";
35 }
36 $dsql->SetQuery($query);
37 $dsql->Execute('t');
38 $result = '';
39 $totalRow = $dsql->GetTotalRow();
40 while($row = $dsql->GetArray('t'))
41 {
42 $arcurl = GetOneArchive($row['id']);
43 $result .= "<li><a href=\"{$arcurl['arcurl']}\">{$row['title']}</a></li>";
44 }
45 if($result=='') $result = "<p style='color:#f00;'> 该TAG标签没有相关文章</p>";
46 @me = $result;
47 [/field:tag]
48 </ul>
49 </dd>
50 </dl>
51 </div>
52 {/dede:tag}

请根据自己的文章列表样式来套用即可。