星联网络专注帝国CMS二次功能插件开发-精品网站模板站长代码素材

  • 最近更新
  • 模板:33
  • 记录:12641|
  • 插件:52|
  • 工具:4|
  • 代码:8|
  • 评论:0

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

前言

本文主要讲解《dedecms调用顶级栏目名称和URL链接》的详细内容

问题:
在2级栏目页面单独调用该栏目的顶级栏目名称!
方法思路:
在 {dede:type} <a href="[field:typelink /]">[field:typename /]</a> {/dede:type} 标签的基础上进行修改。 调用方法: {dede:type2} <a href="[field:typelink /]">[field:typename /]</a> {/dede: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 `dede_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; } } ?>

本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。

本文地址:http://www.xlkjgs.com/notes/web/4430.html

以上内容由本站整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!

星联网络

星联网络是中国最具实战的互联网创业者的知识服务商,这里有互联网行业动态,网络推广,SEO优化,SEM优化,ESC配置,行业经验分型,互联网项目,微信营销、淘宝客赚钱、新媒体营销、京东运营、跨境电商等众多互联网营销知识分享

站长运营站长必备网站运营之道才能长久发展