CMS1.2 首页随机调用影视图片


把乔克作为影视为主的站点,我想很多朋友都在尝试,作为学习者,我也和大家共享一点自己研究的东西。(如果有问题,欢迎高手批评指正!!)

运行环境:乔克CMS1.2+影视插件(同时自己改数据库为SQL了,如果ACCESS数据库的朋友调试出现问题,请修改数据库连接相关语句)

效果:首页随机调用自己定义的一定数量的影片

目的:不经常更新的朋友,可以用这个来弥补,造成更新很快的假相(不提倡弄虚作假,呵呵)

在首页index2.asp文件中加入以下定义:

Code:

sub main_center_video(vname,vgen,c_num,w_num)
dim osql,id,name,pnum
select case vgen
case "hot"
osql=" order by counter desc,id desc"
case "good"
osql=" and star=5 order by tim desc,id desc"
case else
osql=" order by id desc"
end select
pnum=100\c_num
%>
<table cellspacing=1 cellpadding=4 class=table>
<tr><td class=td0> <%response.write vname%></td></tr>
<tr class=bg_td><td>
<table border=0 cellspacing=0 cellpadding=0 width='100%'>
<tr align=center>
<%
if vgen="good" then
Dim idCollection,idArray,n,NN,idResult,idNum,idCount,idBound
idBound=50
set rs=joekoe_cms.exec("select count(id) as idCount from video where hidden=1 and star=5",1)
idCount=rs("idCount")
if idCount>idBound then
idCount=idBound
end if
rs.close
set rs=joekoe_cms.exec("select top " & idBound & " id from video where hidden=1 and star=5 order by id desc",1)
idCollection=""
do while not rs.eof
if n<idCount then
idCollection=idCollection & rs("id") & ","
else
idCollection=idCollection & rs("id")
end if
rs.movenext
loop
idArray=Split(idCollection,",")
idResult=""
idNum=0
do while idNum<6
Randomize()
NN=int(rnd()*Ubound(idArray)+1)
'response.write Ubound(idArray) & "-" & NN
'response.Flush()
if idArray(NN)<>"" then
idResult=idResult & idArray(NN) & ","
idArray(NN)=""
idNum=idNum+1
end if
loop
if len(idResult)>1 then
idResult=Left(idResult,Len(idResult)-1)
end if
rs.close
sql="select id,name,types,genre,lang,star,emoney,power,counter,star,remark,pic from video where id in (" & idResult & ") and hidden=1 and star=5 order by tim desc,id desc"

else
sql="select top "&c_num&" id,name,types,genre,lang,star,emoney,power,counter,star,remark,pic from video where hidden=1"&osql
end if
set rs=joekoe_cms.exec(sql,1)
do while not rs.eof
id=rs("id")
name=rs("name")
%>
<td width='<%'response.write pnum%>%'>
<table border=0 cellspacing=0 cellpadding=0>
<tr><td align=center><%response.write pic_fk(rs("pic"),6,"video_view.asp?id="&id)%></td></tr>
<tr><td align=center><b><a onclick="sAD()" href='video_view.asp?id=<%response.write id%>' alt='<%response.write joekoe_cms.code_html(name,1,0)%>'><%response.write joekoe_cms.code_html(name,1,w_num)%></a></b></td></tr>
</table>
</td>
<%
rs.movenext
loop
rs.close
%>
</tr>
</table>
</td></tr>
</table>
<%
end sub



调用语句:

Code:

call main_center_video("vname","vgen",c_num,w_num)



注解:
main_center_video(vname,vgen,c_num,w_num)中,vname为标题名,vgen为调用热门/推荐/最新,c_num为图片数量,w_num为文字字数。

定义里面的红色部分idBound=50为随机范围,建议不要太大,否则将占用资源明显!

例子(以idBound=50为例):
call main_center_video("社区影吧最新推荐","good",6,6)
调用最新50个推荐里面的随机6个首页显示,用户每次刷新,都会显示最新50个推荐里面的随机6个!!

call main_center_video("社区影吧热门影片","hot",6,6)
调用最热门的前50名影片的随机6个到首页,用户刷新就会变化,呵呵!!

http://www.joekoe.com/forum/view_82243,20.html

文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 8 | 引用: 0 | 查看次数: 1200
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 20 字 | UBB代码 关闭 | [img]标签 关闭