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. leetcode -- Search for a Range (TODO)

    Given a sorted array of integers, find the starting and ending position of a given target value. You ...

  2. 用scikit-learn实现朴素贝叶斯分类器 转

    原文:http://segmentfault.com/a/1190000002472791 朴素贝叶斯(Naive Bayes Classifier)是一种「天真」的算法(假定所有特征发生概率是独立的 ...

  3. AVFoundation视频流处理

    框架 首先我们从整体对所需框架做个初步了解. AVFoundation在相关框架栈中的的位置: 为了捕捉视频,我们需要这样几种类(与其它的子类). AVCaptureDevice 代表了输入设备,例如 ...

  4. 自定义JPA之AttributeConverter

    1. 执行类 public class BooleanConverter implements AttributeConverter<Boolean, Integer> { } 2. 属性 ...

  5. 高效Count

    SQL Server快速查询某张表的当前行数   传统做法可能是select count(1) 但是往往会比较慢.推荐如下做法: SELECT ISNULL(MAX(rowcnt), 0) Curre ...

  6. CF 13E. Holes 分块数组

    题目:点这 跟这题BZOJ 2002: [Hnoi2010]Bounce 弹飞绵羊  一模一样 分析: 分块数组入门题. 具体的可以学习这篇博文以及做国家集训队2008 - 苏煜<对块状链表的一 ...

  7. android代码片段二

      1.Android拦截短信 一.AndroidManifest.xml <uses-permission android:name="android.permission.RECE ...

  8. 转:java 类名 this 的使用

    转自: http://www.cnblogs.com/PengLee/p/3993033.html 类名.class与类名.this详解   类名.class      我们知道在java中,一个类在 ...

  9. 转:OpenResty最佳实践(推荐了解lua语法)

    看点: 1. Lua 语法的说明, 排版清晰易懂. 转: https://moonbingbing.gitbooks.io/openresty-best-practices/content/lua/m ...

  10. js中call和apply的用法和区别

    它们的作用都是将函数绑定到另外一个对象上去运行,两者仅在定义参数方式有所区别: obj.call(thisObj, arg1, arg2, ...); obj.apply(thisObj, [arg1 ...