dede在任一子级栏目获取顶级栏目名称 typename,包括
导读:dedecmsdedecms找到 include/taglib/type.lib.php , 复制, 重命名为toptype.lib.php 查找 function lib_type($c织梦模板免费下裁。
找到 include/taglib/type.lib.php , 复制, 重命名为 toptype.lib.php
查找 function lib_type(&$ctag,&$refObj)
修改为:
function lib_toptype(&$ctag,&$refObj)
查找 $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,topid,description,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,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 $dsql,$envs; $attlist='typeid|0'; FillAttsDefault($ctag->CAttribute->Items,$attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = trim($ctag->GetInnerText()); if($typeid==0) { $typeid = ( isset($refObj->TypeLink->TypeInfos['id']) ? $refObj->TypeLink->TypeInfos['id'] : $envs['typeid'] ); } if(empty($typeid)) return ''; 织梦网站模板 //$row = $dsql->GetOne("Select id,topid,description,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typelitpic From `dede_arctype` where id='$typeid' "); $topid=$dsql->GetOne("Select topid From `dede_arctype` where id='$typeid' "); $topid=$topid['topid']; $row=$dsql->GetOne("Select id,topid,description,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typelitpic From `dede_arctype` where id='$topid' "); if(!is_array($row)) return ''; if($row['topid']==0){$row['topid']=$row['id'];} if(trim($innertext)=='') $innertext = GetSysTemplets("part_type_list.htm"); $dtp = new DedeTagParse(); $dtp->SetNameSpace('field','[',']'); $dtp->LoadSource($innertext); if(!is_array($dtp->CTags)) { unset($dtp); return ''; } else { $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row); foreach($dtp->CTags as $tagid=>$ctag) { if(isset($row[$ctag->GetName()])) $dtp->Assign($tagid,$row[$ctag->GetName()]); } $revalue = $dtp->GetResult(); unset($dtp); return $revalue; } }声明: 本文由我的SEOUC技术文章主页发布于:2023-07-19 ,文章dede在任一子级栏目获取顶级栏目名称 typename,包括主要讲述栏目,名称,dedecms网站建设源码以及服务器配置搭建相关技术文章。转载请保留链接: https://www.seouc.com/article/web_30140.html