网站模板中心

您现在的位置:首页>>织梦大学>>织梦技巧

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

来源: 编辑:admin 发布时间:2020-03-05热度:73 ℃
织梦 s 调用顶级栏目名称和URL链接。 问题: 在2级栏目页面单独调用该栏目的顶级栏目名称! 方法思路: 在 {dede:type} a href=[field:typelink /][field:typename /]/a {/dede:type} 标签的基础上进...
织梦dedecms调用顶级栏目名称和URL链接。
问题: 
 
在2级栏目页面单独调用该栏目的顶级栏目名称! 
 
方法思路: 
 
{dede:type}
{/dede:type}
标签的基础上进行修改。
 
调用方法:
{dede:type2}
{/dede:type2}
 
新标签放置位置:
01 include aglib ype2.lib.php保存为type2.lib.php标签就可以使用
02  
03
04 /* vim: set expandtab tabstop=4 shiftwidth=4: */
05 // +----------------------------------------------------------------------+
06 // | PHP version 5                                                        |
07 // +----------------------------------------------------------------------+
08 // | Copyright (c) 1997-2004 The PHP Group                                |
09 // +----------------------------------------------------------------------+
10 // | This source file is subject to version 3.0 of the PHP license,       |
11 // | that is bundled with this package in the file LICENSE, and is        |
12 // | available through the world-wide-web at the following url:           |
13 // | http://www.php.net/license/3_0.txt.                                  |
14 // | If you did not receive a copy of the PHP license and are unable to   |
15 // | obtain it through the world-wide-web, please send a note to          |
16 // | license@php.net so we can mail you a copy immediately.               |
17 // +----------------------------------------------------------------------+
18 // | Authors: Original Author                         |
19 // |          Your Name                                  |
20 // +----------------------------------------------------------------------+
21 //
22 // $Id:$
23  
24 if (!defined('DEDEINC')) exit('Request Error!');
25 function lib_type2(&$ctag, &$refObj) {
26     global $dsql$envs;
27     $attlist 'typeid|0';
28     FillAttsDefault($ctag->CAttribute->Items, $attlist);
29     extract($ctag->CAttribute->Items, EXTR_SKIP);
30     $innertext = trim($ctag->GetInnerText());
31     if ($typeid == 0) {
32         $typeid = (isset($refObj->TypeLink->TypeInfos['topid']) ? $refObj->TypeLink->TypeInfos['topid'] : $envs['typeid']);
33 //echo "ssssssssss1".$refObj->TypeLink->TypeInfos['topid'];
34 //echo "ssssssssss2".$envs['typeid']; exit;
35     }
36 //echo "typeid:".$typeid; exit;
37 //lyy 如果topid==0 就是顶级分类,取当前记录
38 if($refObj->TypeLink->TypeInfos['topid']==0){
39 $typeid=$refObj->TypeLink->TypeInfos['id'];
40 }
41 //echo "typeid:".$typeid; exit;
42     if (empty($typeid)) return '';
43  $row $dsql->GetOne("SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
44                           FROM `dede_arctype` WHERE id='$typeid'");
45  
46     if (!is_array($row)) return '';
47     if (trim($innertext) == ''$innertext = GetSysTemplets("part_type_list.htm");
48     $dtp new DedeTagParse();
49     $dtp->SetNameSpace('field''['']');
50     $dtp->LoadSource($innertext);
51     if (!is_array($dtp->CTags)) {
52         unset($dtp);
53         return '';
54     else {
55 //lyy 以下getTypeUrl($row[topid]错的,换成 $row['id'] echo  $row['id']."sssss";exit;
56         $row['typelink'] = GetTypeUrl($row['id'], MfTypedir($row['typedir']) ,$row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'],$row['siteurl'], $row['sitepath']);
57  
58 //print_r($row);exit;
59         foreach ($dtp->CTags as $tagid => $ctag) {
60             if (isset($row[$ctag->GetName() ])) $dtp->Assign($tagid$row[$ctag->GetName() ]);
61         }
62         $revalue $dtp->GetResult();
63         unset($dtp);
64         return $revalue;
65     }
66 } ?>

Pbootcms问题解决

请点击在线联系我们【点击咨询解决问题】   如果您有任何Pbootcms问题,我们将免费为您写解决教程!

    PB模板网:承接仿站业务,价格200元起!