官方dede:tag默认只能调用指定的1个栏目的,无法指定多个栏目
例如,我要调用指定的1,2,3这个几个栏目和子栏目的TAG标签出来
{dede:tag row='30' sort='new' getall='1' typeid='1,2,3'}<a href="[field:link/]">[field:tag/]</a>{/dede:tag}
解决方法
打开 /include/taglib/tag.lib.php 找到 ,大概在67行左右
$addsql = " WHERE typeid='$typeid' ";
改成
//指定了多个栏目时
if( preg_match('#,#', $typeid) )
{
$typeids = explode(',', $typeid);
foreach($typeids as $ttid) {
$typeidss[] = GetSonIds($ttid);
}
$typeidStr = join(',', $typeidss);
$typeidss = explode(',', $typeidStr);
$typeidssok = array_unique($typeidss);
$typeid = join(',', $typeidssok);
$addsql = " WHERE typeid IN ($typeid) ";
}
else
{
$addsql = " WHERE typeid IN (".GetSonIds($typeid).") ";
}
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
如图
