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 ...
随机推荐
- debian7编译内核
第一个步骤“配置内核”. 在这里,我比较建议在发行版默认的config的基础上再进行配置,这样 配置出的内核和发行版本身才会有更好的相容性.比如可以在运行“make menuconfig”之前执行命令 ...
- 详解MySQL中EXPLAIN解释命令
Explain 结果解读与实践 基于 MySQL 5.0.67 ,存储引擎 MyISAM . 注:单独一行的"%%"及"`"表示分隔内容,就象分开“第一 ...
- 用VB操作Excel的方法
VB是常用的应用软件开发工具之一,由于VB的报表功能有限,而且一但报表格式发生变化,就得相应修改程序,给应用软件的维护工作带来极大的不便.因此有很多程序员现在已经充分利用EXECL的强大报表功来实现报 ...
- DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements SingletonBeanRegistry
// 用于内部标记的空的单例对象(不支持null)protected static final Object NULL_OBJECT = new Object(); // 缓存单例对象根据beanNa ...
- Android(java)学习笔记90:泛型类的概述和使用
用法一: 下面我们首先定义泛型类: package cn.itcast_04; /* * 泛型类:把泛型定义在类上 */ public class ObjectTool<T> { //这里 ...
- python(1) - 第一个程序 Hello World!
进入python3的解释器环境. 我们让解释器输出 “Hello World!” 解释器成功的输出了Hello world! 程序就这样完成了. 当然上面的程序我们是在解释器中完成的. 我们可以通过 ...
- [转]Response.AddHeader 文本下载
本文转自:http://hi.baidu.com/yuxi981/item/7c617fc41b03ad60f6c95d30 Response.AddHeader实现下载 /// <su ...
- HTML5自带的原生定位
使用谷歌的,与百度有偏差,一般不推荐使用 一.window.navigator.geolocation 验证浏览器是否支持 if (window.navigator.geolocation) { ...
- HTML5和Web Apps框架和方法
单页: 1jQuery Mobile 该框架以其基于AJAX的导航系统和可使用主题的ThemeRoller设计而闻名.支持Android,ios,Windows Phone,webOs等.编程模式为C ...
- Jersey(1.19.1) - Representations and Java Types
Previous sections on @Produces and @Consumes referred to MIME media types of representations and sho ...