本文档由橙子博客维护
模版引用
<%if not in_sdcms then response.write("template load fail"):response.end() end if%>
模版文件路径引用
<script src="{webroot}theme/default/js/sdcms.js"></script>
动态文件引用
{sdcms:include("../../sdcms_head.asp")}
常用标签
栏目名称 | {classname} | 栏目关键字 | {seokey} |
栏目描述 | {seodesc} | 优化标题 | {seotitle} |
栏目ID | {classid} | 栏目所有父ID | {parentid} |
分页数量 | {pagenum} | 栏目所有子ID | {sonid} |
栏目图片 | {catepic} | 栏目模型ID | {modeid} |
栏目最上级栏目ID | {topid} | ||
类别名称 | {sdcms.getcatename(1)} | 类别的Url | {sdcms.getcateurl(1)} |
过滤掉html代码,并再次截取前90个数字 | {sdcms.cutstr(sdcms.nohtml($rs[content]),90,1)} |
标题、关键词、描述
<title>{sdcms.iif(sdcms.strlen(seotitle)>0,seotitle,classname)}{if page>1}_第{page}页{/if}_{sdcms[webname]}</title> <meta name="Keywords" content="{seokey}" /> <meta name="Description" content="{seodesc}" /> <meta name="author" content="{weburl}" /> <meta name="copyright" content="{weburl}" /> <link rel="canonical" href="{weburl}{sdcms.getcateurl(classid)}"/> <script>var webroot="{webroot}",murl="list.asp?classid={classid}";</script> <script src="{webroot}lib/js/jquery.js"></script> {if sdcms[sys_mobile]}<script src="{webroot}lib/js/mobile.js"></script>{/if}
输出分类
{sdcms:rs top="0" table="sd_category" where="followid=[classid]" order="ordnum,cateid" var="cid:cateid"} {sdcms:rp top="0" table="sd_category" where="followid=[cid]" order="ordnum,cateid" var="sid:cateid"} {sdcms:rx top="0" table="sd_category" where="followid=[sid]" order="ordnum,cateid"} {/sdcms:rx} {/sdcms:rp} {/sdcms:rs}
<ul class="topcate"> {sdcms:rp table="sd_category" top="0" where="followid=[classid]" order="ordnum,cateid"} {rp:eof}{if followid=0}<li class="hover"><a href="{sdcms.getcateurl(classid)}">{classname}</a></dt>{else}{sdcms:rs table="sd_category" top="0" where="followid=[followid]" order="ordnum,cateid"} {rs:eof}<li>没有资料</li>{/rs:eof} <li {if $rs[cateid]=classid} class="hover"{/if}><a href="{$rs[link]}" title="{$rs[catename]}">{$rs[catename]}</a></li> {/sdcms:rs}{/if}{/rp:eof} <li {if $rp[cateid]=classid} class="hover"{/if}><a href="{$rp[link]}" title="{$rp[catename]}">{$rp[catename]}</a></li> {/sdcms:rp} </ul>
经典案例
查询全部当前分类: where="cateid in ([parentid]) or followid in ([parentid])"
查询当前下级分类: where="followid in ([parentid])"
查询当前分类(除了一级分类):followid in ([parentid]) and depth=2
输出列表
<div id="photolist"> <ul class="photolist"> {sdcms:rs field="id,isurl,url,title,style,classid,pic,ispic,intro" table="sd_content" where="classid in([sonid]) and islock=1" order="ontop desc,id desc" pagesize="{var pagenum}"} {rs:eof}<li>没有资料</li>{/rs:eof} <li><a href="{$rs[link]}" title="{$rs[title]}"><img src="{if $rs[ispic]=1}{$rs[pic]}{else}{webroot}theme/default/images/nophoto.jpg{/if}" width="130" alt="{$rs[title]}" /></a><div><a href="{$rs[link]}" title="{$rs[title]}">{sdcms.cutstr($rs[title],10,0)}</a></div><p>{sdcms.cutstr(sdcms.nohtml($rs[intro]),40,1)}</p></li> {/sdcms:rs} </ul> </div>
<div class="w610 b"> <div class="title">{classname}</div> <ul class="newslist"> {sdcms:rs field="id,isurl,url,title,style,classid,point,createdate" table="sd_content" where="classid in([sonid]) and islock=1" order="ontop desc,id desc" pagesize="{var pagenum}"} {rs:eof}<li>没有资料</li>{/rs:eof} <li><span>{sdcms.getdate($rs[createdate],".",0)}</span>· <a href="{$rs[link]}" title="{$rs[title]}"{if $rs[isurl]=1} target="_blank"{/if} {$rs[style]}>{sdcms.cutstr($rs[title],90,1)}</a></li> {if i mod 5=0}<li class="mid"></li>{/if} {/sdcms:rs} </ul> <div class="list_page page_group c mt15"><ul>{showpage}</ul></div> </div>
查询内容
{sdcms:rs top="6" field="*" table="sd_content" where="islock=1 and classid in ([sdcms.get_sonid(1)])" order="ontop desc,id desc" auto="i"} {/sdcms:rs}
下面是单页内容输出
{sdcms:rs table="sd_model_page" top="1" where="classid=[classid]"} {sdcms.get_content_split($rs[content],htmlrule)} {/sdcms:rs} {if [get_content_page]<>""}<div class="npage">{get_content_page}</div>{/if}
查询栏目
{sdcms:rs table="sd_category" top="0" where="cateid in ([sdcms.get_sonid(1)])" order="ordnum,cateid" var="sdcms_cateid:cateid"} {/sdcms:rs}
或者: where="followid=2"
分页代码
<div class="list_page page_group c mt15"><ul>{showpage}</ul></div>
分页样式
/*list*/ .list_page{text-align:center;margin:10px;display:block;} .list_page:after{content:" ";display:block;height:0;clear:both;visibility:hidden;overflow:hidden;} .list_page ul{list-style:none;margin:0;padding:0;display:inline-block;vertical-align:bottom;} .list_page ul li{display:inline-block;border:solid 1px #ddd;border-radius:4px;} .list_page ul a{color:#333;padding:8px 12px;line-height:18px;display:block;transition:all 1s cubic-bezier(0.175, 0.885, 0.32, 1) 0s;background:#fff;} .page_group ul{border-right:solid 1px #ddd;border-radius:4px;} .page_group ul li{border-right:none;border-radius:0;float:left;} .page_group ul li:not(:first-child):not(:last-child){border-radius:0;} .page_group ul li:first-child{border-radius:4px 0 0 4px;} .page_group ul li:last-child{border-radius:0 4px 4px 0;} .page_group ul .active a{background:#f3f3f3;border-radius:0;}