zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Beginning SDL 2.0(5) 基于MFC和SDL的YuvPlayer
    Beginning SDL 2.0(6) 音频渲染及wav播放
    Beginning SDL 2.0(4) YUV加载及渲染
    Beginning SDL 2.0(3) SDL介绍及BMP渲染
    获取windows可执行文件的version信息(版本号)
    visual studio 2005提示脚本错误 /VC/VCWizards/2052/Common.js
    Beginning SDL 2.0(2) TwinklebearDev SDL 2.0 Tutorial
    Beginning SDL 2.0(1) SDL功能简介
    ffmpeg与H264编码指南
    2015-07学习总结——网络编程(TCP/IP)
  • 原文地址:https://www.cnblogs.com/qigege/p/5048529.html
Copyright © 2011-2022 走看看