织梦dedecms调用顶级栏目名称和URL链接。

问题:
在2级栏目页面单独调用该栏目的顶级栏目名称!
方法思路:
{dede:type}
<a href=”a , . . +http://wwL w M =w.dede58.com/a/dedejq/[field:typelink /]”>[field:typename /]</a>
{/dede:type}
标签的基础上进行修改。
调用方法:
{dede:type2}
<a href=”http://\ O . J [www.dede58.com/a/dedejq/[field:typelink /]”&g5 M 7 1t;[field:typename /]</a>Y 7 ] P : p r B
{/dede:type2}
新标签放置位置:
\inclM i Hude\taglib\type2.lib.php保存为type2.lib.php标签就可以使2 M _ r d E / K Y用
&} - h S e q Hlt;?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------4 V o , S----------+
// | PHP version 5                                                        |
// +----------------------------------------------------------------------+
// | Cg k Copyright (G t q dc) 1997-2004 The PHP Group                                |
//u r 0 O +------------------------------------------------@ $ d } L F i K ~----------------------+
// | This source file is subject to version 3.0 of the PHP, ; h M / license,       |
// | that is bundleD g Od with this package in the file LICENSE, and is        |
// | available through the worl6 8 / P Kd-wide-web at the following u] ( - 9 Hrl:           |
// | http://www.php.net/license/3_0.txt.                                  |
// | If you did not receive a copy of the PHP license and are unabld | 1 @ S _ ( ~ \e to   |
// | obtain it through the world-wide-web, please send a$ g Y note to          |
/* J ~ T E 1 K/ | license@php.? W $ X D Bnet so we can mail you a copy immediately.               |
// +----------------------------------------9 S U ~------------------------------+
// | Autr l ] I V B ; P Zhors: Original Author <author@exa@ y ? H I I a bmple.com>                        |
// |          Your Name <you@example.com&i x o T & 2 wgt;                                 |
// +----------------------------------------------------------------------+
/// ] I ( k
// $IC z ( R ]d:$
if (!deff \ m h k Y &ined('DEDEINC')) exit('Request Error!');
function lib_type2(&$ctag, &$refObj) {
global $dsQ w L & eql, $envs;m J @ s F y t
$attlist = 'typeid|0';
Fil1 w ( U / ; ?lAttsDefault(+ # ) K s y ; } #$ctag->CAttributej * y i->Itev } ims, $attlist);
extract($ctag->CAttribute->Items, EXTR_SK] h D U t Y YIP);
$innertext = trim($ct) ! = N G @ag->G_ ] K wetInnerText());
if ($typeid == 0) {
$typeid = (isset($refObj->Typ2 ] deLink->TypeIn2 * s P \ dfos['topid']) ? $refObj->TypeLink->TyC K t C | 5peInfos['topid'] : $envs['typeid']);
//echo "ssssssssss1".$refObj->v d p n ! 8 . 6 c;TypeLink->TypeInfos['topid'];
//echo "ssssssssss2".$envs['typeid']; exit;
}
//echo "typeid:".$typeid; exd + C 9 Y g Nit;/ E \ G S C Q
//lyy 如果y v # y p r y ctopid==0 就p d a ` r是顶级分类,取当前记录
if($refObj->TypeLink->TypeInfos['topid']==0)l \ S ~ 1{
$typeid=$refObj->TypeLink] i U l e N - K-&gh Y . @ 3 M qt;TypeInfos['id'];
}
//echo "typeid:".$typeid; exit;
if (empty($typeid)) return '';
$row = $dsql->GetOne("SELECT id,typename,typedir,isdefault,ispV / \ W 0 = .au , M Art,defaultname,namerule2,moresiG z # w $ Z V %te,siteurl,sitepath
FROM `dede_arctype` WHERE id='$typeid'");
if (!is_array($rP _ 4 V H * yow)) return '';
if (trim($innertext) == '') $innertext = GetSysTemplv _ Q T c v +ets("part_ty- 9 K Y * 3 K Epe_list.htm");
$dtp = new DedeTagParse();
$dtp->SetNameSpace('field', '[', ']');
$dtp->Loa! g fdSource($innertext);% n q I D .
if (!is_array($dtp->CTags)) {
unset($dtp);
returC ^ g R fn '';
} else {
//lyy 以下getTypeUrW C Kl($row[topid]错的,U f U l k换成 $roR v 3w['id'] echo  $row2 I S 7 H 3 X R 5['id']."sssss";exit;
$row['typelink'] = GetTypeUrl($row['id'], MfTypedir($row['typedir']) , $row['isdefault'], $row['defaultname'], $row['ispart'], $roN I Vw['namerule2'], $row['siteurl'], $row['sitepath']);
//print_r($ro( 3 t A + , ` Ww);exit;
foreach ($dtp->CTa[ V = }gs as $tagid => $ctag) {
if (isv G - H F r = ]set($row[$ctag->GetName() ])) $dtp->Assign($! K 8tagid,6 K ! _ K p | $row[$ctag->GetName() ]);
}
$ree | nvalue = $dtp->GetResul? F t Q R c W \t();
unset($dtp);
return $revalue;
}
} ?> 

免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。/ Q Q b . f ,

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注