c#代码中
<%csharp%>string parent_id=DTRequest.GetQueryString("parent_id"); if(parent_id!=""&&category_id==0) { category_id=Convert.ToInt32(parent_id); } <%/csharp%>
展示一级
- 分类:
- <%if(parent_id=="")%> ">全部 <%else%> ">全部 <%/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 %> <%if(({strtoint(parent_id)}=={strtoint({cdr[id]})})||(category_id=={strtoint({cdr[id]})}))%> ">{cdr[title]}(<%=GetCount(channel,{cdr[id]}," status=0 ") %>) <%else%> ">{cdr[title]}(<%=GetCount(channel,{cdr[id]}," status=0 ") %>) <%/if%> <%else%> <%if(({strtoint(parent_id)}=={strtoint({cdr[id]})})||(category_id=={strtoint({cdr[id]})}))%> ">{cdr[title]}(<%=GetCount(channel,{cdr[id]}," status=0 ") %>) <%else%> ">{cdr[title]}(<%=GetCount(channel,{cdr[id]}," status=0 ") %>) <%/if%> <%/if %> <%/foreach%>
展示二级栏目
<%if {strtoint(parent_id)}!=0%>
- 二级分类:
- <%set DataTable childrenList1=get_category_child_list(channel,{strtoint(parent_id)})%> <%foreach(DataRow chd in childrenList1.Rows)%> <%if(category_id=={strtoint({chd[id]})})%> ">{chd[title]}(<%=GetCount(channel,{chd[id]}," status=0 ") %>) <%else%> ">{chd[title]}(<%=GetCount(channel,{chd[id]}," status=0 ") %>) <%/if%> <%/foreach%>
最终效果
注意规格或者排序中需要加上parent_id参数
案例网址