找到 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
;
}
}
?>
如果想获取任一栏目的上级栏目,可将topid---->改为--->reid,最后记得改函数名和文件名
retype.lib.php
<?php
if
(!defined(
'DEDEINC'
))
exit
(
'Request Error!'
);
function
lib_retype(&
$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' ");
$reid
=
$dsql
->GetOne(
"Select reid From `dede_arctype` where id='$typeid' "
);
$reid
=
$reid
[
'reid'
];
$row
=
$dsql
->GetOne(
"Select id,reid,description,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,typelitpic From `dede_arctype` where id='$reid' "
);
if
(!
is_array
(
$row
))
return
''
;
if
(
$row
[
'reid'
]==0){
$row
[
'reid'
]=
$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
;
}
}
?>
模板调用: {dede:retype}[field:typename/]{/dede:retype}
上一篇:自定义搜索的链接写法
下一篇:修改{dede:list}标签后,可支持权重排序、flag标签功能
郑重声明:
本站所有内容均由互联网收集整理、网友上传,并且以计算机技术研究交流为目的,仅供大家参考、学习,不存在任何商业目的与商业用途。
若您需要商业运营或用于其他商业活动,请您购买正版授权并合法使用。
我们不承担任何技术及版权问题,且不对任何资源负法律责任。
如无法下载,联系站长索要。
如有侵犯您的版权,请给我们来信:cainiaovip8@qq.com,我们尽快处理。