c#代码中

  <!--C#代码-->
<%csharp%>
string parent_id=DTRequest.GetQueryString("parent_id");
 if(parent_id!=""&&category_id==0)
        {
            category_id=Convert.ToInt32(parent_id);
          
        }
<%/csharp%>
<!--/C#代码-->

展示一级

<dl>
<dt>分类:</dt>
<dd>
<%if(parent_id=="")%>
<a class="selected" href="<%linkurl("index")%>">全部</a>
<%else%>
<a href="<%linkurl("index")%>">全部</a>
<%/if%>
<%set DataTable categoryList1=get_category_child_list(channel,0)%>
<%foreach(DataRow cdr in categoryList1.Rows)%>
<%set DataTable childrenList=get_category_child_list(channel,{strtoint({cdr[id]})})%>
<%if childrenList.Rows.Count>0 %> <!--表示有二级栏目的情况,注意超链接的写法,此时为parent_id赋值,为后面展示二级栏目做准备 -->
<%if(({strtoint(parent_id)}=={strtoint({cdr[id]})})||(category_id=={strtoint({cdr[id]})}))%>
<a class="selected" href="<%linkurl("index","?parent_id="+{cdr[id]})%>">{cdr[title]}(<%=GetCount(channel,{cdr[id]}," status=0 ") %>)</a>
<%else%>
<a href="<%linkurl("index","?parent_id="+{cdr[id]})%>">{cdr[title]}(<%=GetCount(channel,{cdr[id]}," status=0 ") %>)</a>
<%/if%>
<%else%> <!--表示没有有二级栏目,注意超链接的写法--> <%if(({strtoint(parent_id)}=={strtoint({cdr[id]})})||(category_id=={strtoint({cdr[id]})}))%>
<a class="selected" href="<%linkurl("index","?category_id="+{cdr[id]})%>">{cdr[title]}(<%=GetCount(channel,{cdr[id]}," status=0 ") %>)</a>
<%else%>
<a href="<%linkurl("index","?category_id="+{cdr[id]})%>">{cdr[title]}(<%=GetCount(channel,{cdr[id]}," status=0 ") %>)</a>
<%/if%>
<%/if %>
<%/foreach%>
</dd>
</dl>

展示二级栏目

 <%if {strtoint(parent_id)}!=0%>
<dl><dt>二级分类:</dt>
<dd> <%set DataTable childrenList1=get_category_child_list(channel,{strtoint(parent_id)})%> <%foreach(DataRow chd in childrenList1.Rows)%>
<%if(category_id=={strtoint({chd[id]})})%>
<a class="selected" href="<%linkurl("index","?category_id="+{chd[id]}+"&parent_id="+parent_id)%>">{chd[title]}(<%=GetCount(channel,{chd[id]}," status=0 ") %>)</a>
<%else%>
<a href="<%linkurl("index","?category_id="+{chd[id]}+"&parent_id="+parent_id)%>">{chd[title]}(<%=GetCount(channel,{chd[id]}," status=0 ") %>)</a>
<%/if%>
<%/foreach%> </dd>
</dl> <%/if %>

最终效果

注意规格或者排序中需要加上parent_id参数

案例网址www.vikeycn.com

DTCMS展示一级栏目并展示各自栏目下的二级栏目的更多相关文章

  1. dede调出所有栏目以及栏目下的二级栏目

    1.调出所有栏目以及栏目下的二级栏目 {dede:channelartlist typeid='top'}<a href="{dede:field name='typeurl'/}&q ...

  2. 在list_*页面显示出一级栏目下的所有二级栏目

    <ul class="nav nav-pills nav-stacked"> {dede:channelartlist typeid='1,1'} <div cl ...

  3. PHPCMS-V9 获取一级栏目、二级栏目、三级栏目

    <!-- 获取一级栏目 -->{pc:content action=" siteid="$siteid" order="listorder ASC& ...

  4. phpcms v9二级栏目生成到根目录后三级栏目无法访问的解决办法

    这个栏目问题折腾了我一天多,可怜我这个美工又不会程序!!! 我的问题是: 我的栏目设置如下: 一级栏目[生成到根目录(是)]> 二级栏目[生成到根目录(是)] > 三级栏目[生成到根目录( ...

  5. PHPCMS v9 导航显示二级菜单,显示相邻栏目,内容页显示二级栏目

    导航显示二级栏目 <div class="menu">{pc:content action="category" catid="0&quo ...

  6. Django--CRM--菜单展示, 删除合并, 权限展示

    一 . 菜单展示 二 . 合并删除 我们可以把所有的删除都合并成一个函数这样就会减少很多的代码. 思路: 在url里面需要传两个参数,一个是要删的id 一个是名字 三 .权限展示 我们要实现两个功能 ...

  7. dedecms获取顶级栏目名称、二级栏目名称实现方法 转

    织梦DEDECMS文章.栏目页获取当前页面顶级栏目名称的方法 在用织梦做一些项目时,时常会碰到需要在当前页面调用顶级栏目名称的时候,织梦默认{dede:field name='typename' /} ...

  8. phpcms二级栏目的调用

    1.二级栏目的调用方法 {php $data = subcat($module, $catid);} {loop $data $n $r} {if $r[ismenu]} {$r[catname]} ...

  9. Phpcms V9当前栏目及所有二级栏目下内容调用标签

    在二级栏目列表页调用: <!--* 获取子栏目* @param $parentid 父级id* @param $type 栏目类型* @param $self 是否包含本身 0为不包含* @pa ...

随机推荐

  1. 如何在linux下解压缩rar和zip格式的文件压缩包

    转载:http://oldboy.blog.51cto.com/2561410/597515 使用apt-get安装:  sudo apt-get install  rar  zip rar使用: 将 ...

  2. 面试常备题---二叉树总结篇(zt)

    人生就像是一场长跑,有很多机会,但也得看我们是否能够及时抓牢,就像下面这样的代码: while(isRunning) { if(...){...} else if(...){...} ... else ...

  3. 获取Spring-boot系统环境变量方法

    public static ConfigurableApplicationContext context = null; public static void main( String[] args ...

  4. HTML5 indexedDB数据库的入门学习(一)

    笔者早些时间看过web sql database,但是不再维护和支持,所以最近初步学习了一下indexedDB数据库,首先indexedDB(简称IDB)和web sql database有很大的差别 ...

  5. HDU 1160 FatMouse's Speed (DP)

    FatMouse's Speed Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Su ...

  6. java按行读取txt并按行写入

    IO流想必大家都很熟悉了,本次实现的需求是按行读取文件内容并且按行写入,代码如下: try { String encoding="utf-8"; //设定自己需要的字符编码集 Fi ...

  7. Html5中的video元素

    最近在做门户的时候遇到要显示企业的视频介绍,需要找到一个在aspx页面播放视频的html,最后找到了是一段HTML5最新的html代码,如下: /// <summary> /// 播放视频 ...

  8. Lombok(1.14.8) - @NoArgsConstructor, @RequiredArgsConstructor & @AllArgsConstructor

    @NoArgsConstructor @NoArgsConstructor,提供一个无参的构造方法. package com.huey.hello.bean; import java.util.Dat ...

  9. 开发Android应用 提升性能的小技巧

    前 言 2015年,Android OS 目前在手机操作系统的市场占有率已达59%,权威机构预计,Android市场占有率在2016年将达到63%,由于Android的开放性,未来占有率还将不断增加, ...

  10. android操作通讯录的联系人

    界面配置文件 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     and ...