DEDECMS5.1 Tag首页文章分类显示(2 位领导批示)

dedecms 在5.x版本新增加的 tag 标签.

在首页使用时只有row,sort与InnerText三个参数.而不能像arclist等标签一样可以用typeid参数按文章分类显示.

自己动手.修改了一下

打开 include/inc_arcpart_view.php 文件

首先找到第 222 行

1
2
3
4
5
6
}else if($tagname=="tag"){
    //自定义宏标签
    if(empty($typeid)) $typeid = $envTypeid;
    $this->dtp->Assign($tagid,
    $this->GetTags($ctag->GetAtt("row"),$ctag->GetAtt("sort"),$ctag->GetInnerText())
);

修改为:

1
2
3
4
5
6
7
}else if($tagname=="tag"){
    //自定义宏标签
    $typeid = trim($ctag->GetAtt("typeid"));
    if(empty($typeid)) $typeid = $envTypeid;
    $this->dtp->Assign($tagid,
    $this->GetTags($ctag->GetAtt("row"),$ctag->GetAtt("sort"),$ctag->GetInnerText(),$typeid)
);

然后修改第 557 行的 GetTags 函数为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function GetTags($num,$ltype='new',$InnerText="",$typeid){
	global $cfg_cmspath;
 
	/*luoliang 2008-7-2 edit*/
	if($typeid)
	{
		$typeSql = " where l.typeid in ($typeid)";
	}
	else
	{
		$typeSql = " ";
	}
	/*luoliang 2008-7-2 edited*/
 
	$InnerText = trim($InnerText);
	if($InnerText=="") $InnerText = GetSysTemplets("tag_one.htm");
	$revalue = "";
	if($ltype=='rand') $orderby = ' rand() ';
	else if($ltype=='week') $orderby=' weekcc desc ';
	else if($ltype=='month') $orderby=' monthcc desc ';
	else if($ltype=='hot') $orderby=' count desc ';
	else $orderby = '  id desc  ';
	if(empty($num)) $num = 10;
 
	//$this->dsql->SetQuery("Select tagname,count,monthcc,result From #@__tag_index order by $orderby limit 0,$num");tag_list
 
	/*luoliang 2008-7-2 edit*/
	$this->dsql->SetQuery("Select i.tagname,i.`count`,i.monthcc,i.result From #@__tag_index as i left join #@__tag_list as l on (i.id=l.tid) $typeSql group by l.tid order by $orderby limit 0,$num");
	/*luoliang 2008-7-2 edited*/
 
	$this->dsql->Execute();
	$ctp = new DedeTagParse();
	$ctp->SetNameSpace("field","[","]");
	$ctp->LoadSource($InnerText);
	while($row = $this->dsql->GetArray())
	{
	  $row['keyword'] = $row['tagname'];
	  $row['link'] = $cfg_cmspath."/tag.php?/".urlencode($row['keyword'])."/";
	  $row['highlight'] = $row['keyword'];
	  $row['result'] = trim($row['result']);
	  if(empty($row['result'])) $row['result'] = 0;
 
	  if($ltype=='view'||$ltype=='rand'||$ltype=='new'){
		 if($row['monthcc']>1000 || $row['weekcc']>300 ){
			  $row['highlight'] = "<span style='font-size:".mt_rand(12,16)."px;color:red'><b>{$row['highlight']}</b></span>";
		 }
		 else if($row['result']>150){
			  $row['highlight'] = "<span style='font-size:".mt_rand(12,16)."px;color:blue'>{$row['highlight']}</span>";
		 }
		 else if($row['count']>1000){
			  $row['highlight'] = "<span style='font-size:".mt_rand(12,16)."px;color:red'>{$row['highlight']}</span>";
		 }
	  }else{
		$row['highlight'] = "<span style='font-size:".mt_rand(12,16)."px;'>{$row['highlight']}</span>";
	  }
 
	  foreach($ctp->CTags as $tagid=>$ctag){
	    if(isset($row[$ctag->GetName()])) $ctp->Assign($tagid,$row[$ctag->GetName()]);
	  }
	  $revalue .= $ctp->GetResult();
	}
 
	return $revalue;
}

新增了$typeid参数.注释部分为修改处

调用方法

1
{dede:tag typeid='6,24,25,26,27' row='10' sort='new'}<a href='[field:link/]'>[field:highlight/]</a>{/dede:tag}

分享到新浪微博 推荐到豆瓣 分享到 Google Reader 加入Google书签 嘀咕一下 分享到饭否 分享到做啥 分享到叽歪 分享到鲜果 加入QQ书签 加入百度搜藏 加入雅虎书签 分享到垦一垦

  1. 2
    银子

    @纯真
    说实话 dedecms写得真垃圾..

  2. 1
    纯真

    银子也开始研究DEDECMS了,以后有问题可以请教您了。

请领导指示

验证码 (必须)

Additional comments powered by BackType

随机显示的10篇日志

评论最多的10篇日志

浏览最多的10篇日志