GVKun编程网logo

Dede实现嵌套获取栏目及其子栏目列表(decode嵌套使用)

27

在本文中,我们将带你了解Dede实现嵌套获取栏目及其子栏目列表在这篇文章中,我们将为您详细介绍Dede实现嵌套获取栏目及其子栏目列表的方方面面,并解答decode嵌套使用常见的疑惑,同时我们还将给您一

在本文中,我们将带你了解Dede实现嵌套获取栏目及其子栏目列表在这篇文章中,我们将为您详细介绍Dede实现嵌套获取栏目及其子栏目列表的方方面面,并解答decode嵌套使用常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的dede 调用 栏目子栏目名称问题 @!、dede:channelartlist 获取该栏目下的子栏目列表及内容、DEDECMS v5.5实现嵌套获取栏目及其子栏目列表、DEDECMS 点击主栏目默认显示第一个子栏目列表的方法

本文目录一览:

Dede实现嵌套获取栏目及其子栏目列表(decode嵌套使用)

Dede实现嵌套获取栏目及其子栏目列表(decode嵌套使用)

 

修改 channerl.lib.php

<?php function lib_channel(&$ctag,&$refObj) { global $_sys_globals,$envs,$dsql; $attlist = "typeid|0,reid|0,row|100,col|1,type|son,currentstyle|"; FillAttsDefault($ctag->CAttribute->Items,$attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = $ctag->GetInnerText(); if(empty($typeid) && $envs['typeid']!=0) { $typeid = $envs['typeid']; $reid = $envs['reid']; }else{ $reid=0; } if($type==''||$type=='sun') $type="son"; if($innertext=='') $innertext = GetSysTemplets("channel_list.htm"); if($reid==0 && $typeid>0) { $dbrow = $dsql->GetOne("Select reid From dede_arctype where id='$typeid' "); if(is_array($dbrow)) $reid = $dbrow['reid']; } $likeType = ''; if($type=='top') { $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description From dede_arctype where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row"; } else if($type=="son") { //if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid']; if($typeid==0) { return ''; } $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description From dede_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row"; } else if($type=="self") { if($reid==0) { return ''; } $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description From `dede_arctype` where reid='$reid' And ishidden<>1 order by sortrank asc limit 0,$row"; } //And id<>'$typeid' $dtp2 = new DedeTagParse(); $dtp2->SetNameSpace("field","[","]"); $dtp2->LoadSource($innertext); $dsql2 = clone $dsql; $dsql->SetQuery($sql); $dsql->Execute(); $line = $row; $GLOBALS['autoindex'] = 0; for($i=0;$i < $line;$i++) { if($col>1) $likeType .= "<dl>\r\n"; for($j=0;$j<$col;$j++) { if($col>1) $likeType .= "<dd>\r\n"; if($row=$dsql->GetArray()) { if($type=='self' && $row['id']==$typeid) //处理同级栏目中,当前栏目的样式 { if($currentstyle!='') { $linkOkstr = $currentstyle; $row['typelink'] = GetOneTypeUrlA($row); $linkOkstr = str_replace("~typelink~",$row['typelink'],$linkOkstr); $linkOkstr = str_replace("~typename~",$row['typename'],$linkOkstr); $likeType .= $linkOkstr; } }else { $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row); if(is_array($dtp2->CTags)) { foreach($dtp2->CTags as $tagid=>$ctag){ if(isset($row[$ctag->GetName()])) { $dtp2->Assign($tagid,$row[$ctag->GetName()]); } elseif ('sonchannel' == $ctag->GetName()) { $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql2)); } } } $likeType .= $dtp2->GetResult(); } } if($col>1) $likeType .= "</dd>\r\n"; $GLOBALS['autoindex']++; }//Loop Col if($col>1) { $i += $col - 1; $likeType .= " </dl>\r\n"; } }//Loop for $i $dsql->FreeResult(); return $likeType; } function lib_channel_son($ctag,$typeid = 0,$dsql2) { $attlist = "row|100,col|1,currentstyle|"; FillAttsDefault($ctag->CAttribute->Items,$attlist); extract($ctag->CAttribute->Items, EXTR_SKIP); $innertext = $ctag->GetInnerText(); $likeType = ''; //if($_sys_globals['typeid']>0) $typeid = $_sys_globals['typeid']; if($typeid==0) { return ''; } $sql = "Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description From dede_arctype where reid='$typeid' And ishidden<>1 order by sortrank asc limit 0,$row"; //And id<>'$typeid' $dtp2 = new DedeTagParse(); $dtp2->SetNameSpace("field","[","]"); $dtp2->LoadSource($innertext); $dsql2->SetQuery($sql); $dsql2->Execute(); $line = $row; for($i=0;$i < $line;$i++) { if($col>1) $likeType .= "<dl>\r\n"; for($j=0;$j<$col;$j++) { if($col>1) $likeType .= "<dd>\r\n"; if($row=$dsql2->GetArray()) { $row['typelink'] = $row['typeurl'] = GetOneTypeUrlA($row); if(is_array($dtp2->CTags)) { foreach($dtp2->CTags as $tagid=>$ctag){ if(isset($row[$ctag->GetName()])) { $dtp2->Assign($tagid,$row[$ctag->GetName()]); } elseif ('sonchannel' == $ctag->GetName()) { $dtp2->Assign($tagid,lib_channel_son($ctag,$row['id'],$dsql2)); } } } $likeType .= $dtp2->GetResult(); } if($col>1) $likeType .= "</dd>\r\n"; }//Loop Col if($col>1) { $i += $col - 1; $likeType .= " </dl>\r\n"; } }//Loop for $i $dsql2->FreeResult(); return $likeType; } ?>  

源码调用

 

#p#分页标题#e#

{dede:channel type='son' typeid='14'} <div><a href=http://www.dede58.com/a/dedejq/"[field:typelink/]">[field:typename/]</a></div> <ul> [field:sonchannel] <li><a href=http://www.dede58.com/a/dedejq/"[field:typelink/]">[field:typename/]</a></li> [/field:sonchannel] </ul> {/dede:channel}  

本文章网址:http://www.ppssdd.com/code/6453.html。转载请保留出处,谢谢合作!

dede 调用 栏目子栏目名称问题 @!

dede 调用 栏目子栏目名称问题 @!

现在 arclist 显示文章的各种信息,现在想显示文章 所属的 子 栏目名称 不是频道栏目名称 是二级栏目名称

dede:channelartlist 获取该栏目下的子栏目列表及内容

dede:channelartlist 获取该栏目下的子栏目列表及内容

基本语法:

{dede:autochannel partsort='' typeid=’’}{/dede:autochannel}

参数说明:

partsort = '0' 栏目所在的排序位置

typeid=’0’ 获取单个栏目的顶级栏目

底层模板字段:

typename,typelink(仅表示栏目的网址)

获取当前频道的下级栏目的内容列表标签
适用范围:全局使用
基本语法:
{dede:channelartlist row=6}


{dede:field name='typename'/}


{dede:arclist titlelen='42' row='10'}


  • ([field:pubdate function="MyDate('m-d',@me)"/])


{/dede:arclist}

{/dede:channelartlist}
参数说明:
typeid = '0' 频道ID,多个请用","分隔
row = '20' 获取的栏目返回值
其他说明:
除了宏标记外,channelArtlist 是唯一一个可以直接嵌套其它标记的标记,不过仅限于嵌套
{dede:type}{/dede:type} 和 {dede:arclist}{/dede:arclist} 两个标记。
底层模板变量:
包含{dede:type}{/dede:type}及{dede:arclist}{/dede:arclist}下面所有底层模板变量

特殊应用

{dede:field name='id'} 获取该栏目的 子栏目的ID 即 typeid

DEDECMS v5.5实现嵌套获取栏目及其子栏目列表

DEDECMS v5.5实现嵌套获取栏目及其子栏目列表

  小编 jb51.cc 关于Dedecms实现嵌套获取栏目及其子栏目列表的问题,在论坛找到了以前版本的修改方法,用在5.5版本上发现不能用,于是修改了一下,现在分享给大家。请看实例代码:

  修改文件:include aglib目录下的channel.lib.PHP,请将以下代码全部复制替换上述文件。

以下为引用的内容:
<?PHP
function lib_channel(&$ctag,&$refObj)
{
    global $_sys_globals,$envs,$dsql;
    $attlist = typeid|0,reid|0,row|100,col|1,type|son,currentstyle|;
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
    extract($ctag->CAttribute->Items,EXTR_SKIP);
    $innertext = $ctag->GetInnerText();
        $cacheid = trim($cacheid);
    if($cacheid !='''') {
        $likeType = GetCacheBlock($cacheid);
        if($likeType != '''') return $likeType;
    }

    $reid = 0;
    $topid = 0;
    if(empty($typeid) && $envs[''typeid'']!=0)
    {
        $typeid = $envs[''typeid''];
        $reid = $envs[''reid''];
    }else{
        $reid=0;
    }

    if($type==''''||$type==''sun'') $type=son;
    if($innertext=='''') $innertext = GetSystemplets(channel_list.htm);

    if($reid==0 && $typeid>0)
    {
        $dbrow = $dsql->Getone(Select reid From dede_arctype where id=''$typeid'' );
        if(is_array($dbrow)) $reid = $dbrow[''reid''];
    }

    $likeType = '''';
    if($type==''top'')
    {
        $sql = Select id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath,description
          From dede_arctype where reid=0 And ishidden<>1 order by sortrank asc limit 0,$row;
    }
    else if($type==son)
    {
        //if($_sys_globals[''typeid'']>0) $typeid = $_sys_globals[''typeid''];
        if($typeid==0) {
            return '''';
        }
        $sql = Select id,description
          From dede_arctype where reid=''$typeid'' And ishidden<>1 order by sortrank asc limit 0,$row;
    }
    else if($type==self)
    {
        if($reid==0) {
            return '''';
        }
        $sql = Select id,description
            From `dede_arctype` where reid=''$reid'' And ishidden<>1 order by sortrank asc limit 0,$row;
    }
    //And id<>''$typeid''
    $needRel = false;
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace(field,[,]);
    $dtp2->LoadSource($innertext);
    $dsql2 = clone $dsql;
    $dsql->SetQuery($sql);
    $dsql->Execute();

    $line = $row;
        //检查是否有子栏目,并返回rel提示(用于二级菜单)本教程由网提供,更多http://www.veryhuo.com/
    if(ereg('':rel'',$innertext)) $needRel = true;
    
    if(empty($sql)) return '''';
    $dsql->SetQuery($sql);
    $dsql->Execute();
    
    $totalRow = $dsql->GetTotalRow();
    $GLOBALS[''autoindex''] = 0;
    for($i=0;$i < $line;$i++)
    {
        if($col>1) $likeType .= <dl>;
        for($j=0;$j<$col;$j++)
        {
            if($col>1) $likeType .= <dd>;
            if($row=$dsql->GetArray())
            {
                            $row[''sonids''] = $row[''rel''] = '''';
                if($needRel)
                {
                    $row[''sonids''] = GetSonIds($row[''id''],false);
                    if($row[''sonids'']=='''') $row[''rel''] = '''';
                    else $row[''rel''] = rel=''dropmenu{$row[''id'']}'';
                }
                //处理同级栏目中,当前栏目的样式
                if( ($row[''id'']==$typeid || ($topid==$row[''id''] && $type==''top'') ) && $currentstyle!='''' )
                {
                    if($currentstyle!='''')
                    {
                    $linkOkstr = $currentstyle;
                    $row[''typelink''] = GetoneTypeUrlA($row);
                    $linkOkstr = str_replace(~rel~,$row[''rel''],$linkOkstr);
                    $linkOkstr = str_replace(~id~,$row[''id''],$linkOkstr);
                    $linkOkstr = str_replace(~typelink~,$row[''typelink''],$linkOkstr);
                    $linkOkstr = str_replace(~typename~,$row[''typename''],$linkOkstr);
                    $likeType .= $linkOkstr;
                    }
                }else
                {
                    $row[''typelink''] = $row[''typeurl''] = GetoneTypeUrlA($row);
                    if(is_array($dtp2->CTags))
                    {
                        foreach($dtp2->CTags as $tagid=>$ctag){
                            if(isset($row[$ctag->GetName()]))
                            {
                                $dtp2->Assign($tagid,$row[$ctag->GetName()]);
                            }
                            elseif (preg_match(''/^sonchannel[0-9]*$/'',$ctag->GetName()))
                            {
                                $dtp2->Assign($tagid,lib_channel_son($ctag,$dsql2));
                            }
                        }
                    }
                    $likeType .= $dtp2->GetResult();
                }
            }
            if($col>1) $likeType .= </dd>;
            $GLOBALS[''autoindex'']++;
        }//Loop Col
        if($col>1)
        {
            $i += $col - 1;
            $likeType .=     </dl>;
        }
    }//Loop for $i
    reset($dsql2);
    $dsql->FreeResult();
    return $likeType;
}
function lib_channel_son($ctag,$typeid = 0,$dsql2)
{
    $attlist = row|100,EXTR_SKIP);
    $innertext = $ctag->GetInnerText();
    $dsql3 = clone $dsql2;
    $likeType = '''';

    //if($_sys_globals[''typeid'']>0) $typeid = $_sys_globals[''typeid''];
    if($typeid==0) {
        return '''';
    }
    $sql = Select id,$row;
    //And id<>''$typeid''
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace(field,]);
    $dtp2->LoadSource($innertext);
    $dsql2->SetQuery($sql);
    $dsql2->Execute();
    $line = $row;

    for($i=0;$i < $line;$i++)
    {
        if($col>1) $likeType .= <dl>;
        for($j=0;$j<$col;$j++)
        {
            if($col>1) $likeType .= <dd>;
            if($row=$dsql2->GetArray())
            {
                $row[''typelink''] = $row[''typeurl''] = GetoneTypeUrlA($row);
                if(is_array($dtp2->CTags))
                {
                    foreach($dtp2->CTags as $tagid=>$ctag){
                        if(isset($row[$ctag->GetName()]))
                        {
                            $dtp2->Assign($tagid,$row[$ctag->GetName()]);
                        }
                        elseif (preg_match(''/^sonchannel[0-9]*$/'',$ctag->GetName()))
                        {
                            $dtp2->Assign($tagid,$dsql3));
                        }
                    }
                }
                $likeType .= $dtp2->GetResult();
            }
            if($col>1) $likeType .= </dd>;
        }//Loop Col
        if($col>1)
        {
            $i += $col - 1;
            $likeType .=     </dl>;
        }
    }//Loop for $i
    reset($dsql3);
    $dsql2->FreeResult();
    return $likeType;
}
?>

总结

以上是小编为你收集整理的DEDECMS v5.5实现嵌套获取栏目及其子栏目列表全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

DEDECMS 点击主栏目默认显示第一个子栏目列表的方法

DEDECMS 点击主栏目默认显示第一个子栏目列表的方法

数据技术都能四世同堂,凭什么开发 30 岁就要被干掉?
本文实例讲述了 DEDECMS 点击主栏目默认显示第一个子栏目列表的方法。分享给大家供大家参考。具体分析如下:

今天公司有个需求是,点击导航上的父栏目进去默认显示第一个子栏目的列表,以下是具体实现方法,可能有点笨,呵呵.

第一步:新建模版,比如 oneUrl.htm, 内容如下,注,以下内容写到 javascript 标签里.

代码如下:

{dede:channel type=''son'' row=''1''}

window.location.href=''[field:typelink /]'';

{/dede:channel}

第二步:到后台 “核心 -> 网站栏目管理 -> 要修改的主栏目 ”, 然后点击修改,主要修改以下几项.

1, 常规选项 - 栏目属性设置为,频道封面,栏目本身不允许发布文档.

2, 高级选项 - 封面模版设置为,第一步新建的模版即可.

实现原理就是,点击父栏目会 查询第一个子栏目的链接,然后做跳转操作.

(大宝库)

本文同步分享在 博客 “lxw1844912514”(CSDN)。
如有侵权,请联系 support@oschina.cn 删除。
本文参与 “OSC 源创计划”,欢迎正在阅读的你也加入,一起分享。

关于Dede实现嵌套获取栏目及其子栏目列表decode嵌套使用的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于dede 调用 栏目子栏目名称问题 @!、dede:channelartlist 获取该栏目下的子栏目列表及内容、DEDECMS v5.5实现嵌套获取栏目及其子栏目列表、DEDECMS 点击主栏目默认显示第一个子栏目列表的方法的相关信息,请在本站寻找。

本文标签: