首页 > 其他 > 详细

DTCMS展示一级栏目并展示各自栏目下的二级栏目

时间:2015-12-15 15:55:51      阅读:223      评论:0      收藏:0      [点我收藏+]

c#代码中

  <!--C#代码-->
    <%csharp%>
string parent_id=DTRequest.GetQueryString("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!=0 -->
            <%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 %>

 

DTCMS展示一级栏目并展示各自栏目下的二级栏目

原文:http://www.cnblogs.com/qigege/p/5048529.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!