kingCMS ASP5.1如何调用子分类所有文章并实现分页?

这篇文章是之前的解决办法,后来好像有了第2中办法,因为KingCMS后台已经有了这个功能,并且支持前台调用;可参考:

https://www.yantailao.com/kingcms/kingcms-classes.html

如果无法实现的话,不妨参考下面的方式修改:

首先要打开站点根目录下page/article/fun.asp文件,在文件底部加个函数,见
function king_article_suball(l1) ‘根据listid递归找到其子listid
dim ids,tempids,rs
king_article_suball = l1
set rs=conn.execute(“select listid from kingart_list where listid1 in (“&l1&”) ;”)
if not rs.eof and not rs.bof then
tempids=rs.getString(,,””,”,”,””)
if len(tempids)>0 and InStr(tempids,”,”) then
tempids = left(tempids,len(tempids)-1)
end if
rs.close
king_article_suball=king_article_suball(tempids)&”,”&king_article_suball
else
king_article_suball=l1
end if
end function
然后找到找到本页面大约330或340行左右 把createlist1函数用以下代码替换
public sub createlist1(l1,l2)
dim tmphtm,outhtm
dim tmphtmlist,tmplist
dim jshtm,jsnumber,zebra
dim rs,irs,i,j,dp,data,datalist,pid,plist,pidcount,count,length’pidcount 总页数
dim sql,suij,suijpagelist
dim jsorder,listid,listpath,listname
if len(l1)=0 then exit sub
sql=”listid,listname,listpath,listtemplate1,listtemplate2,listtitle,listkeyword,listdescription,listcontent”‘7 datalist
set rs=conn.execute(“select “&sql&” from kingart_list where listid=”&l1&”;”)
if not rs.eof and not rs.bof then
datalist=rs.getrows()
else
redim datalist(0,-1)
end if
rs.close
set rs=nothing
sql=”a.artid,a.listid,arttitle,a.artfrom,artdescription,artdate,artkeywords,a.artauthor,’/’+b.listpath+’/’+artpath,artimg,artgrade”’10 data
‘分析模板及标签,并获得值
tmphtm=king.read(datalist(3,0),r_path&”

      /”&datalist(4,0))’内外部模板结合后的htm代码

 

      tmphtmlist=king.getlist(tmphtm,”article”,1)’type=”list”部分的tag,包括{king:/}

 

      jshtm=king.getlabel(tmphtmlist,0)

 

      jsorder=king.getlabel(tmphtmlist,”order”)

 

      if lcase(jsorder)=”asc” then jsorder=”asc” else jsorder=”desc”

 

      jsnumber=fix(king.getlabel(tmphtmlist,”number”))

 

      zebra=king.getlabel(tmphtmlist,”zebra”)

 

      suij=chr(3)&salt(20)&chr(2)’随机出来的替换参数

 

      suijpagelist=chr(3)&salt(16)&chr(2)

 

      dim jslevel,insql_id

 

      jslevel=king.getlabel(tmphtmlist,”level”)

 

      select case lcase(jslevel)

 

      case”sub”

 

      insql_id=” a.listid in (“&king_article_suball(l1)&”)”

 

      case”current”

 

      insql_id=” a.listid=”&l1

 

      case”all”

 

      insql_id1=” a.listid<>0 “

 

      case else

 

      insql_id=” a.listid=”&l1

 

      end select

 

      ‘把tmphtm中的{king:…type=list/}标签替换为一个随机的标签;pagelist设置为一个随机标签

 

      tmphtm=replace(tmphtm,tmphtmlist,suij)

 

      ‘替换模板中的标签

 

      king.clearvalue

 

      king.value “title”,encode(htmlencode(datalist(5,0)))

 

      king.value “listname”,encode(htmlencode(datalist(1,0)))

 

      king.value “listcontent”,encode(htmlencode(datalist(8,0)))

 

      king.value “listpath”,encode(king.inst&datalist(2,0))

 

      king.value “keywords”,encode(htmlencode(datalist(6,0)))

 

      king.value “description”,encode(htmlencode(datalist(7,0)))

 

      king.value “path”,encode(king.inst&datalist(2,0))

 

      king.value “pagelist”,encode(suijpagelist)

 

      king.value “listid”,datalist(0,0)

 

      king.value “guide”,encode(guide(datalist(0,0))) ‘增加,可选的

 

      tmphtm=king.create(tmphtm,king.invalue)

 

      set dp=new record

 

      dp.pid=l2

 

      dp.rn=jsnumber

 

      dp.create “select “&sql&” from kingart a,kingart_list b where a.listid = b.listid and artshow=1 and (“&insql_id&” or listids like ‘%,”&datalist(0,0)&”,%’) order by artup desc,artorder “&jsorder&”,a.artid “&jsorder&”;”
      if dp.length>-1 then

 

      ‘初始化变量值

 

      pid=l2

 

      count=dp.count’总记录数

 

      pidcount=dp.pagecount’总页数

 

      length=dp.length’页记录数

 

      for i=0 to length’开始循环列表
      king.clearvalue

 

      king.value “artid”,dp.data(0,i)

 

      king.value “listid”,dp.data(1,i)

 

      king.value “listname”,encode(htmlencode(datalist(1,0)))

 

      king.value “listcontent”,encode(htmlencode(datalist(8,0)))

 

      king.value “listpath”,encode(king.inst&datalist(2,0))

 

      king.value “title”,encode(htmlencode(dp.data(2,i)))

 

      king.value “from”,encode(formatfrom(dp.data(3,i)))

 

      king.value “description”,encode(htmlencode(dp.data(4,i)))

 

      king.value “date”,encode(htmlencode(dp.data(5,i)))

 

      king.value “keywords”,encode(htmlencode(dp.data(6,i)))

 

      king.value “author”,encode(htmlencode(dp.data(7,i)))

 

      king.value “image”,encode(dp.data(9,i))

 

      king.value “path”,encode(getpath(dp.data(0,i),dp.data(10,i),dp.data(8,i)))

 

      king.value “zebra”,king.mod2(i+1,zebra)

 

      king.value “commentid”,encode(r_path&”|”&dp.data(0,i))’传递评论参数

 

      tmplist=tmplist&king.createhtm(jshtm,king.invalue)’循环累加值到tmplist变量

 

      next

 

      plist=pagelist(king.inst&datalist(2,0)&”/$/”,pid,pidcount,count)

 

      outhtm=replace(tmphtm,suij,tmplist)

 

      outhtm=replace(outhtm,suijpagelist,plist)

 

      king.createfolder “../../”&datalist(2,0)

 

      if pid=1 then’列表第一页

 

      king.savetofile “../../”&datalist(2,0)&”/”&king_ext,outhtm

 

      else

 

      king.savetofile “../../”&datalist(2,0)&”/”&pid&”/”&king_ext,outhtm

 

      end if

 

      else

 

      outhtm=replace(tmphtm,suij,king.lang(“error/rsnot”))

 

      outhtm=replace(outhtm,suijpagelist,””)

 

      king.savetofile “../../”&datalist(2,0)&”/”&king_ext,outhtm

 

      end if

 

      if l2<pidcount then createlist1 l1,l2+1

 

      set dp=nothing

 

      end sub

******************************涉及到不同版本****我这里已经可以生成分页************

      调用请参考:

 

      调用代码,level=sub,调用本分类及子分类下所有文章,current,仅调用本分类下文章,all,调用根目录下所有文章(不知道有用没,加上再说,哈哈)

 

      {king:article type=”list” level=”sub” number=”2″}

 

      <h5><a href=”(king:path/)”>(king:title/)</a></h5>

 

      <p>(king:description size=”200″/)</p>

 

      <p><i>(king:date mode=”yy-MM-dd”/)</i><a href=”(king:path/)”>(king:siteurl/)(king:path/)</a></p>

 

      {/king}

******************************如果以上未能解决分页问题*****************

      打开根目录下admin/article/index.asp文件,找到 460行:for i=1 to getlistpidcount(I1(nid))

 

      整个for循环用以下代码替换,这里不再需要循环。

 

      pct=int(((fix(ncount)+i)/listpidcounts)*100)

 

      j=Timer

 

      art.createlist1 I1(nid),1

 

      II “<script>window.parent.progress(‘progress’,'”&king.lang(“progress/createlist”)&pct&”%’,'”&king.lang(“progress/usetime”)&formattime(ntime+(Timer-starttime))&”‘,'”&pct&”%’);$(‘body’).prepend(‘<p>- [“&I1(nid)&”] [“&(fix(ncount))&”/”&listpidcounts&”] “&king.lang(“progress/createtime”)&formattime(Timer-j)&”</p>’)</script>”

*****************************KINGCMS放2级目录,列表页生成后产品链接错误为根目录导致无法打开的解决*******

      sql=”a.artid,a.listid,arttitle,a.artfrom,artdescription,artdate,artkeywords,a.artauthor,’/’+b.listpath+’/’+artpath,artimg,artgrade”’10 data

 

      ‘分析模板及标签,并获得值

 

      tmphtm=king.read(datalist(3,0),r_path&”
    找到上面代码: 把

 

    ‘/’+b.listpath+’/’+artpath 修改为:

 

      ‘../../’+b.listpath+’/’+artpath

声明:未经上传用户或原创作者授权,请勿作他用。
其他事微信:93547942 协助处理。
砚台酪-18年专业互联网服务咨询 » kingCMS ASP5.1如何调用子分类所有文章并实现分页?
在线客服
在线客服
热线电话
QQ客服