DEDECMS5.1 Tag首页文章分类显示

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

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

自己动手.修改了一下

打开 include/inc_arcpart_view.php 文件

首先找到第 222 行


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

修改为:


}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 函数为


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'] = "{$row[’highlight’]}“;
		 }
		 else if($row[’result’]>150){
			  $row[’highlight’] = “{$row[’highlight’]}“;
		 }
		 else if($row[’count’]>1000){
			  $row[’highlight’] = “{$row[’highlight’]}“;
		 }
	  }else{
		$row[’highlight’] = “{$row[’highlight’]}“;
	  }

	  foreach($ctp->CTags as $tagid=>$ctag){
	    if(isset($row[$ctag->GetName()])) $ctp->Assign($tagid,$row[$ctag->GetName()]);
	  }
	  $revalue .= $ctp->GetResult();
	}

	return $revalue;
}

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

调用方法


{dede:tag typeid='6,24,25,26,27' row='10' sort='new'}[field:highlight/]{/dede:tag}

2 条评论

  1. 银子

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

  2. 纯真

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

发表评论

验证码: 验证码看不清发泄点这里

 

浏览最多的10篇日志

评论最多的10篇日志

随机显示的10篇日志