dede在任一子级栏目获取顶级栏目名称 typename,包括该顶级栏目下

找到 include/taglib/type.lib.PHP,复制, 重命名为 toptype.lib.PHP

查找 function lib_type(&$ctag,&$refObj)

修改为:

function lib_toptype(&$ctag,宋体;"> 查找 $row = $dsql->Getone

注释掉 //$row = $dsql->Getone("Select id,topid,description,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typelitpic From `dede_arctype` where id='$typeid' ");

添加3行:

$topid=$dsql->Getone("Select topid From `dede_arctype` where id='$typeid' ");
$topid=$topid['topid'];
$row=$dsql->Getone("Select id,typelitpic From `dede_arctype` where id='$topid' ");

模板调用: {dede:toptype}[field:typename/]{/dede:toptype}

修改后的toptype.lib.PHP

	
PHP
 
if(!defined('DEDEINC')) exit('Request Error!');
 
function lib_toptype(&$ctag,&$refObj)
{
    global $dsqlPHP plain" style="font-family: Consolas,$envs;
 
    $attlist='typeid|0';
    FillAttsDefault(->CAttribute->Items,monospace !important; padding: 0px !important; margin: 0px !important; color: black !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; Box-sizing: content-Box !important; font-size: 1em !important; background: none !important;">);
extract(PHP variable" style="font-family: Consolas,EXTR_SKIP);
$innertext = trim(->GetInnerText());
 
($typeid==0) {
        $typeid = ( isset(->TypeLink->TypeInfos['id']) ? ] : ['typeid'] );
}
 
  (empty)) return '';
 
    //$row = $dsql->Getone("Select id,typelitpic From `dede_arctype` where id='$typeid' ");
 
$topid=->Getone("Select topid From `dede_arctype` where id='$typeid' ");
'topid'];
$row"Select id,typelitpic From `dede_arctype` where id='$topid' ");
    
(!is_array;
]==0){]=];}
(trim($innertext)=== GetSystemplets("part_type_list.htm");
    
$dtp new DedeTagParse();
$dtp->SetNameSpace('field'PHP plain" style="font-family: Consolas,'['']');
->LoadSource();
->CTags))
{
        unset();
        ;
}
else
{
'typelink'] = 'typeurl'] = GetoneTypeUrlA();
foreach->CTags as $tagid=>)
{
            (isset([->GetName()])) ->Assign(->GetName()]);
}
$revalue ->GetResult();
);
return $revalue;
}
}

 

?>

如果想获取任一栏目的上级栏目,可将topid---->改为--->reid,最后记得改函数名和文件

retype.lib.PHP

		
PHP
 
(!defined()) ();
 
function lib_retype(&,monospace !important; padding: 0px !important; margin: 0px !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; Box-sizing: content-Box !important; font-size: 1em !important; background: none !important;">)
{
global ;
 
=;
FillAttsDefault(->CAttribute->Items,monospace !important; padding: 0px !important; margin: 0px !important; border-radius: 0px !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; Box-sizing: content-Box !important; font-size: 1em !important; background: none !important;">);
extract(PHP variable" style="font-family: Consolas,EXTR_SKIP);
$innertext = trim(->GetInnerText());
 
(==0) {
$typeid = ( isset(->TypeLink->TypeInfos[]) ? ] : [] );
}
 
()) return ;
 
PHP plain" style="font-family: Consolas,typelitpic From `dede_arctype` where id='$typeid' ");
 
$reid=->Getone("Select reid From `dede_arctype` where id='$typeid' ");
'reid'];
PHP plain" style="font-family: Consolas,reid,typelitpic From `dede_arctype` where id='$reid' ");
    
(!;
]==0){]=];}
(trim()==) = GetSystemplets();
    
$dtp = new DedeTagParse();
->SetNameSpace();
->LoadSource();
->CTags))
{
unset();
;
}
else
{
] = ] = GetoneTypeUrlA();
->CTags as =>)
{
(isset([->GetName()])) ->Assign(->GetName()]);
}
$revalue = ->GetResult();
);
return ;
}
}

 

?>

模板调用: {dede:retype}[field:typename/]{/dede:retype}

相关文章

织梦模板建站更换logo的操作步骤:1.找到logo图片所在文件位...
织梦更适合企业建站,织梦拥有大量免费的漂亮模版,简单易用...
在织梦中设置404页面的方法1.进入织梦网站后台管理界面,在界...
解决织梦系统漏洞的方法有以下几种1.将data、templets、uplo...
织梦网站漏洞的解决办法:1.删除install安装目录。2.定期进行...
修改织梦建站变默认路径的方法:1.进入织梦cms;2.选择“系统...