首页的“推荐产品”改为调用“图片新闻”的方法
作者:cmscn 日期:2005-04-11
先是在skin.asp里面增加
定义
dim tmp_img_hh
web_img_m="m_"&m_channel
web_img_h="h_"&m_channel
tmp_img_hh=web_img_h
在最下面的适当位置增加
function news_bar_topp(tvar,tt,ttype,tmore)
dim w_wid,more_var,temp1
w_wid="20%"
if len(tvar)>10 then w_wid="45%"
if len(tvar)>25 then w_wid="70%"
if int(ttype)=2 then w_wid="45%"
'more_var="<img
src='"&joekoe_cms.web_dir_skin&"main/"&m_channel&"_more_0"&ttype&".gif' border=0>"
if tmore<>"" or var_null(tmore)<>"" then
more_var=""
end if
web_img_h=tmp_img_hh&ttype
temp1=vbcrlf&"<table border=0 cellspacing=0 cellpadding=0 class=tablew>" & _
vbcrlf&"<tr><td class=td>" & _
vbcrlf&" <table border=0 cellspacing=0 cellpadding=0 width='100%'>" & _
vbcrlf&" <tr height=23>" & _
vbcrlf&" <td width='"&w_wid&"' class=td> <font
class=btd>"&tvar&"</font></td>" & _
vbcrlf&" <td width='*' align=right>"&more_var&" </td>" & _
vbcrlf&" </tr>" & _
vbcrlf&" </table>" & _
vbcrlf&"</td></tr>" & _
vbcrlf&"<tr><td align=center>"
if tt=1 then temp1=temp1&vbcrlf&" <table border=0 width='100%'>"
news_bar_topp=temp1
end function
function news_bar_endd(mvar,tt)
dim temp1
if tt=1 then temp1=temp1&vbcrlf&" </table>"
temp1=temp1&vbcrlf&"</td></tr>" & _
vbcrlf&"</table>"
news_bar_endd=temp1&ukong
end function
sub news_picc(nt,n_num,c_num,n_title)
dim temp1,nid,per_num,n_topic
per_num=100
_num
response.write vbcrlf&news_bar_topp(n_title,1,1,"news_list.asp?action=pic") & _
vbcrlf&"<tr align=center>"
sql="select top "&n_num&" id,topic,pic from news where hidden=1 and ispic=1"
select case nt
case "hot"
sql=sql&" order by counter desc,id desc"
case "good"
sql=sql&" and istop=1 order by id desc"
case else
sql=sql&" order by id desc"
end select
set rs=joekoe_cms.exec(sql,1)
do while not rs.eof
n_topic=rs("topic")
response.write vbcrlf&"<td
width='"&per_num&"%'>"&format_pic_type(rs("pic"),n_topic,c_num,"news_view.asp?id="&rs("i
d"))&"</td>"
rs.movenext
loop
rs.close
response.write vbcrlf&"</tr>" & _
vbcrlf&news_bar_endd("",1)
end sub
在首页调用
call news_picc("good",3,12,"图片新闻")
相关帖子:http://www.joekoe.com/forum_view.asp?forum_id=7&view_id=45455
图片新闻调用另一方法
sub main_center_newpic(cs_tnum,cs_cnum)
dim tmp1,tmp_topic,tmp_url,tmp2
tmp1=vbcrlf&"<tr align=center>"
sql="select top "&cs_tnum&" id,topic,pic from news where hidden=1 and ispic=1 order by id desc"
set rs=joekoe_cms.exec(sql,1)
do while not rs.eof
tmp_topic=rs(1)
tmp_url="news_view.asp?id="&rs(0)
tmp1=tmp1&vbcrlf&"<td>" & _
vbcrlf&" <table border=0 cellspacing=0 cellpadding=0>" & _
vbcrlf&" <tr><td align=center>"&pic_fk(rs("pic"),1,tmp_url)&"</td></tr>" & _
vbcrlf&" <tr><td align=center height="&dim_num(6)&"><a href='"&tmp_url&"' target=_blank>"&joekoe_cms.code_html(tmp_topic,1,cs_cnum)&"</a></td></tr>" & _
vbcrlf&" </table>" & _
vbcrlf&"</td>"
rs.movenext
loop
rs.close
tmp1=tmp1&vbcrlf&"</tr>"
tmp1="<table border=0 cellspacing=0 cellpadding=2 width='100%'>"&tmp1&vbcrlf&"</table>"
response.write vbcrlf&"<table cellspacing=1 cellpadding=4 >" & _
vbcrlf&"<tr><td class=td0> 图片新闻</td></tr>" & _
vbcrlf&"<tr ><td>"&tmp1&"</td></td></tr>" & _
vbcrlf&"</table>"&ukong
end sub
调用:
call main_center_newpic(4,标题字数)
楼主说明:好象此方法还有一点问题,当标题字数设为12时,标题栏宽度过大,设为11或10时,标题栏宽度又不够!
本人已修改完善:
将红色部分修改为:
tmp1=tmp1&vbcrlf&"</tr>"
tmp1="<table border=0 cellspacing=0 cellpadding=2 width='100%'>"&tmp1&vbcrlf&"</table>"
response.write vbcrlf&"<table cellspacing=1 cellpadding=4 class=table>" & _
vbcrlf&"<tr><td class=td0> 图片新闻</td></tr>" & _
vbcrlf&"<tr class=bg_td><td align=center>"&tmp1&"</td></tr>" & _
vbcrlf&"</table>"&ukong
end sub
测试成功!
相关帖子:http://www.joekoe.com/forum_view.asp?forum_id=7&view_id=45599
评论: 5 | 引用: 0 | 查看次数: 717
发表评论