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

2016-07-12dedecms开发
1448

问题: 
 
在2级栏目页面单独调用该栏目的顶级栏目名称! 
 
方法思路: 
 
{wmd:type}
<a href="[field:typelink /]">[field:typename /]</a> 
{/wmd:type}
标签的基础上进行修改。
 
调用方法:
{wmd:type2}
<a href="[field:typelink /]">[field:typename /]</a> 
{/wmd:type2}
 
新标签放置位置:
\include\taglib\type2.lib.php保存为type2.lib.php标签就可以使用
 
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 5                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.php.net/license/3_0.txt.                                  |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: Original Author <author@example.com>                        |
// |          Your Name <you@example.com>                                 |
// +----------------------------------------------------------------------+
//
// $Id:$
 
if (!defined('DEDEINC')) exit('Request Error!');
function lib_type2(&$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['topid']) ? $refObj->TypeLink->TypeInfos['topid'] : $envs['typeid']);
//echo "ssssssssss1".$refObj->TypeLink->TypeInfos['topid'];
//echo "ssssssssss2".$envs['typeid']; exit;
    }
//echo "typeid:".$typeid; exit;
//lyy 如果topid==0 就是顶级分类,取当前记录
if($refObj->TypeLink->TypeInfos['topid']==0){
$typeid=$refObj->TypeLink->TypeInfos['id'];
}
//echo "typeid:".$typeid; exit;
    if (empty($typeid)) return '';
 $row = $dsql->GetOne("SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath 
                          FROM `wmd_arctype` WHERE id='$typeid'");
 
    if (!is_array($row)) return '';
    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 {
//lyy 以下getTypeUrl($row[topid]错的,换成 $row['id'] echo  $row['id']."sssss";exit;
        $row['typelink'] = GetTypeUrl($row['id'], MfTypedir($row['typedir']) , $row['isdefault'], $row['defaultname'], $row['ispart'], $row['namerule2'], $row['siteurl'], $row['sitepath']);
 
//print_r($row);exit;
        foreach ($dtp->CTags as $tagid => $ctag) {
            if (isset($row[$ctag->GetName() ])) $dtp->Assign($tagid, $row[$ctag->GetName() ]);
        }
        $revalue = $dtp->GetResult();
        unset($dtp);
        return $revalue;
    }
} ?> 
 
The End

相关推荐

织梦cms批量删除所有无效TAGS的办法
使用过DedeCMS的站长应当都遇到过这样的问题,在我们删掉一些文章内容后,tags标识中就慢慢拥有许多失效的标识存有,这种TAGS标识并不会跟随大家删掉文章内容一起删掉,如果是受欢迎的词还行,有很多文章内容都是有,如果是小众词,便会发生在TAGS目录有词,...
2023-08-17 dedecms开发
181

怎么修改织梦DEDECMS源码tags标签字数限制
修改织梦DEDECMS中TAG标签字数长度限制的方法共两个步骤,分别是对数据库字数和提交文件的字数进行修改。 一、我们通过织梦DEDECMS后台程序中的系统设置栏目下的SQL命令行工具,来修改数据库中表wmd_tagindex 和wmd_taglist的tag字段属性,将TAG字段属性中...
2023-02-16 dedecms开发
196

织梦dedecms列表页实现第一页与其他页调用不同模板的办法
我们想让dedecms织梦第一页与其他第二页、第三页、、、后面的页调用的不同模板,这个要怎么实现呢? 第一步 修改核心文件 打开 /include/arc.listview.class.php 找到,大概在第330行 $this-ParseDMFields($this-PageNo,1); 在它的上面加入: $tempfile = $GL...
2022-11-19 dedecms开发
195

织梦dedecms调用当前栏目文章数的方法
这篇文章给大家分享的是有关织梦dedecms调用当前栏目文章数的方法的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。 做模板时,经常需要为每个栏目加上此栏目的文章数。和大家分享下实现的方法,此方法适合5.6及5.7、5.7sp1其它...
2022-11-05 dedecms开发
186

dedecms织梦无需登录注册可下单购买的修改
dedecms织梦无需登录注册可下单购买的修改,首先找到/plus/carbuaction.php文件,找到如下代码: //确认用户登录信息if($cfg_ml-IsLogin()){ $userid = $cfg_ml-M_ID;}else{ $username = trim($username); $password = trim($password); if(empty($username)...
2022-11-02 dedecms开发
171

DEDECMS织梦复制https链接网站图片无法本地化的解决办法
现在许多网站使用了SSL技术,网站采用https链接,我们在复制https链接网站的内容,发现图片无法本地化,那么我们想要将这些图片本地化,要怎么操作呢? 第一步: 找到dede/inc/inc_archives_functions.php (注:前边红色的dede目录是您的后台目录) 定位到...
2022-06-15 dedecms开发
125