织梦获取文章副栏目名称及链接的代码

查看次数:  编辑:sorry404  时间:2014-05-10 03:11

百度了一些全是狗屎错误的调用方法调用出来只是栏目id号浪费时间,下面织梦获取文章副栏目名称及链接的代码本人亲测正确
在article_article.htm页面添加标签 {dede:field.typeid2llink/}用来获取副栏目连接。

修改include/arc.archives.class.php文件,在125行后面添加:

 代码如下  


$ks = split(',', $this->Fields['typeid2']); 

 $type2name=""; 

 foreach($ks as $k){ 

 $k = trim($k); 

 if ($k!="") { 

 if ($rowa =$this->dsql->GetOne("select *,ID as id1 from `dede_arctype` where id=".$k)){ 

 $type_path=GetTypeUrl($rowa['id1'],MfTypedir($rowa['typedir']),$rowa['isdefault'],$rowa['defaultname'],$rowa['ispart'],$rowa['namerule2'],$rowa['siteurl']); 

 $type2name.="<a href='".$type_path."' target=_blank>".$rowa['typename']."</a> "; 

 } 

 } 

 } 

 $this->Fields['typeid2llink'] =substr($type2name,0,strlen($type2name)-1); 

首页、列表页标签(在arclist、list等文章列表标签里用):

           [field:typeid2 runphp='yes']

global $dsql;
if(strstr(@me, ',')){
    $typeid2s = explode(',', @me);
    $typename2 = '';
    foreach($typeid2s as $tid){
        $sql = GetSonIds($tid);
        $row = $dsql->GetOne("select * from dede_arctype where id=$tid");
        $row['typeurl'] = GetTypeUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);
        $typename2 .= '<a href="'.$row['typeurl'].'" target="_blank">'.$row['typename'].'</a> ';
    }
}else{
    $row = $dsql->GetOne("select * from dede_arctype where id=@me");
    $row['typeurl'] = GetTypeUrl($row['typeid'],$row['typedir'],$row['isdefault'],$row['defaultname'],$row['ispart'],$row['namerule2'],$row['moresite'],$row['siteurl'],$row['sitepath']);
    $typename2 = '<a href="'.$row['typeurl'].'" target="_blank">'.$row['typename'].'</a>';
}
@me = $typename2;
[/field:typeid2]