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

前端之家收集整理的这篇文章主要介绍了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}

原文链接:https://www.f2er.com/dedecms/451591.html

猜你在找的Dedecms相关文章