DTCMS展示一级栏目并展示各自栏目下的二级栏目
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展示一级栏目并展示各自栏目下的二级栏目的更多相关文章
- dede调出所有栏目以及栏目下的二级栏目
1.调出所有栏目以及栏目下的二级栏目 {dede:channelartlist typeid='top'}<a href="{dede:field name='typeurl'/}&q ...
- 在list_*页面显示出一级栏目下的所有二级栏目
<ul class="nav nav-pills nav-stacked"> {dede:channelartlist typeid='1,1'} <div cl ...
- PHPCMS-V9 获取一级栏目、二级栏目、三级栏目
<!-- 获取一级栏目 -->{pc:content action=" siteid="$siteid" order="listorder ASC& ...
- phpcms v9二级栏目生成到根目录后三级栏目无法访问的解决办法
这个栏目问题折腾了我一天多,可怜我这个美工又不会程序!!! 我的问题是: 我的栏目设置如下: 一级栏目[生成到根目录(是)]> 二级栏目[生成到根目录(是)] > 三级栏目[生成到根目录( ...
- PHPCMS v9 导航显示二级菜单,显示相邻栏目,内容页显示二级栏目
导航显示二级栏目 <div class="menu">{pc:content action="category" catid="0&quo ...
- Django--CRM--菜单展示, 删除合并, 权限展示
一 . 菜单展示 二 . 合并删除 我们可以把所有的删除都合并成一个函数这样就会减少很多的代码. 思路: 在url里面需要传两个参数,一个是要删的id 一个是名字 三 .权限展示 我们要实现两个功能 ...
- dedecms获取顶级栏目名称、二级栏目名称实现方法 转
织梦DEDECMS文章.栏目页获取当前页面顶级栏目名称的方法 在用织梦做一些项目时,时常会碰到需要在当前页面调用顶级栏目名称的时候,织梦默认{dede:field name='typename' /} ...
- phpcms二级栏目的调用
1.二级栏目的调用方法 {php $data = subcat($module, $catid);} {loop $data $n $r} {if $r[ismenu]} {$r[catname]} ...
- Phpcms V9当前栏目及所有二级栏目下内容调用标签
在二级栏目列表页调用: <!--* 获取子栏目* @param $parentid 父级id* @param $type 栏目类型* @param $self 是否包含本身 0为不包含* @pa ...
随机推荐
- javascript运行机制之执行顺序详解(转)
转自http://www.admin10000.com/document/3385.html JavaScript是一种描述型脚本语言,它不同于java或C#等编译性语言,它不需要进行编译成中间语言, ...
- Redis 哈希(Hash)
Redis hash 是一个string类型的field和value的映射表,hash特别适合用于存储对象. Redis 中每个 hash 可以存储 232 - 1 键值对(40多亿). 实例 red ...
- CentOS5.6 安装RabbitMQ
步骤参考官方地址:http://www.rabbitmq.com/install-rpm.html我们这个版本按照官方的不能正确安装. 1.安装erlang(官网地址http://www.erlang ...
- session超时和cookie过期
一.Cookie的过期和Session的超时有什么区别? 会话的超时由服务器来维护,它不同于Cookie的失效日期.首先,会话一般基于驻留内存的cookie不是持续性的cookie,因而也就没有截至日 ...
- hadoop学习记录(二)HDFS java api
FSDateinputStream 对象 FileSystem对象中的open()方法返回的是FSDateInputStream对象,改类继承了java.io.DateInoutStream接口.支持 ...
- git merge branches
git clone url #克隆新的版本库 git init git pull repo_name #有关联的远程库,抽取并和本地合并 git fetch remote_repo_name #抽取并 ...
- python(3)-动态参数实现字符串格式化
s1 = "{0} ===> {1}" s = s1.format('lilei', 'boy') print(s) l = ['lilei', 'boy'] s = s1. ...
- P6Spy 、 SQL Profiler
P6Spy 在优化Hibernate性能的时候,很重要的一点就是要看到Hibernate底层执行的SQL 虽然通过打印日志配合Hibernate的show_sql属性能够拼凑出Hibernate底层执 ...
- CF A and B and Chess
A and B and Chess time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- poj 1364 差分约束
思路:设dis[i]为从0点到第i点的序列总和.那么对于A B gt k 来讲意思是dis[B+A]-dis[A]>k; 对于A B lt k来讲就是dis[B+A]-dis[A]<k; ...