您现在的位置: 阿标在线 >> 技术文章 >> 本站作品 >> 动力3.62相关 >> 正文

362首页和文章频道页图文幻灯片效果

[ 录入:chinar | 点击数: | 更新时间:2005-8-5 7:36:00]

第一步,找到inc文件夹里面的syscode_Article.asp文件,用fp或dw将其打开,在倒数第一行前面即在%>前面,加上以下代码。

'================================================
'过程名:ShowPicArticle1
'作  用:滚动显示新闻图片文章  给大家一个图片幻灯片效果的代码
'参  数:intClassID  ----栏目ID,0为所有栏目,若大于0,则显示指定栏目及其子栏目的图片文章
'        ArticleNum  ----最多显示多少篇文章
'        TitleLen   ----标题最多字符数,一个汉字=两个英文字符
'        ImgWidth   ----图片宽度
'        ImgHeight  ----图片高度
'        Hot        ----是否是热门文章
'        Elite      ----是否是推荐文章
'=================================================
Function ShowPicArticle1(intClassID,ArticleNum,TitleLen,ImgWidth,ImgHeight,Hot,Elite)
dim sqlPic,i,tClass,trs,arrClassID,AD_title,showpicc
if ArticleNum<0 or ArticleNum>=50 then
ArticleNum=5
end if
if ImgWidth<0 or ImgWidth>500 then
ImgWidth=160
end if
if ImgHeight<0 or ImgHeight>500 then
ImgHeight=120
end if
if Hot<>True and Hot<>False then
Hot=False
end if
if Elite<>True and Elite<>False then
Elite=False
end if
sqlPic="select top " & ArticleNum
sqlPic=sqlPic & " A.ArticleID,A.ClassID,L.LayoutID,L.LayoutFileName,A.Title,A.Key,A.Author,A.CopyFrom,A.UpdateTime,A.Editor,A.TitleFontColor,A.TitleFontType,"
sqlPic=sqlPic & " A.Hits,A.OnTop,A.Hot,A.Elite,A.Passed,A.IncludePic,A.Stars,A.PaginationType,A.ReadLevel,A.ReadPoint,A.DefaultPicUrl from Article A"
sqlPic=sqlPic & " inner join Layout L on A.LayoutID=L.LayoutID where A.Deleted=False and A.Passed=True and DefaultPicUrl<>''"

if intClassID>0 then
set tClass=conn.execute("select ClassID,Child,ParentPath from ArticleClass where ClassID=" & intClassID)
if not(tClass.bof and tClass.eof) then
  if tClass(1)>0 then
   arrClassID=ClassID
   set trs=conn.execute("select ClassID from ArticleClass where ParentID=" & tClass(0) & " or ParentPath like '%" & tClass(2) & "," & tClass(0) & ",%' and Child=0 and LinkUrl=''")
   do while not trs.eof
    arrClassID=arrClassID & "," & trs(0)
    trs.movenext
   loop
   set trs=nothing
   sqlPic=sqlPic & " and A.ClassID in (" & arrClassID & ")"
  else
   sqlPic=sqlPic & " and A.ClassID=" & tClass(0)
  end if
  set trs=nothing
else
  sqlPic=sqlPic & " and A.ClassID=" & tClass(0)
end if
set tClass=nothing
end if

if Hot=True then
sqlPic=sqlPic & " and A.Hits>=" & HitsOfHot
end if

if Elite=True then
sqlPic=sqlPic & " and A.Elite=True "
end if

sqlPic=sqlPic & " order by A.OnTop,A.ArticleID desc"
set rsPic=Server.CreateObject("ADODB.Recordset")
rsPic.open sqlPic,conn,1,1

if rsPic.bof and rsPic.eof then
showpicc = showpicc &  "<img src='images/NoPic.jpg' width='" & ImgWidth & "' height='" & ImgHeight & "' border='0'><br>没有任何图片文章"
else
showpicc = showpicc &  "<SCRIPT language=javascript>"
showpicc = showpicc &  "var bannerAD=new Array();"
showpicc = showpicc &  "var bannerADlink=new Array();"
showpicc = showpicc &  "var bannerADtitle=new Array();"
showpicc = showpicc &  "var adNum=0;"

AD_title="<A onmouseover=""displayStatusMsg();return document.returnValue"" href=""javascript:jump2url()""><IMG style=""FILTER: revealTrans(duration=2,transition=20)"" width='" & ImgWidth & "' height='" & ImgHeight & "' border=0 src=""" & rsPic("DefaultPicUrl") & """ name=bannerADrotator></A>"
i=0
do while not rsPic.eof
  strPic=""
  call GetPicArticleTitle1(TitleLen,ImgWidth,ImgHeight,i)
  showpicc =  showpicc & strPic     '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  rsPic.movenext
  i=i+1
loop
             showpicc =  showpicc & "var preloadedimages=new Array();"
showpicc =  showpicc & "for (i=1;i<bannerAD.length;i++){"
showpicc =  showpicc & "preloadedimages[i]=new Image();"
showpicc =  showpicc & "preloadedimages[i].src=bannerAD[i];}"

showpicc = showpicc &  "function setTransition(){"
showpicc = showpicc &  "  if (document.all){"
showpicc = showpicc &  "      bannerADrotator.filters.revealTrans.Transition=Math.floor(Math.random()*23);"
  showpicc = showpicc &  "    bannerADrotator.filters.revealTrans.apply();"
showpicc = showpicc &  "  }"
showpicc = showpicc &  "}"

showpicc = showpicc &  "function playTransition(){"
showpicc = showpicc &  "  if (document.all)"
showpicc = showpicc &  "      bannerADrotator.filters.revealTrans.play()"
showpicc = showpicc &  "}"

showpicc = showpicc &  "function nextAd(){"
showpicc = showpicc &  "  if(adNum<bannerAD.length-1)adNum++ ;"
showpicc = showpicc &  "     else adNum=0;"
showpicc = showpicc &  "   setTransition();"
showpicc = showpicc &  "  document.images.bannerADrotator.src=bannerAD[adNum];"
showpicc = showpicc &  "  playTransition();"
showpicc = showpicc &  "  title.innerHTML='<A href=' +bannerADlink[adNum] + '>' + bannerADtitle[adNum] +'</a>';"
showpicc = showpicc &  "  theTimer=setTimeout('nextAd()', 5000);"

showpicc = showpicc &  "}"

showpicc = showpicc &  "function jump2url(){"
showpicc = showpicc &  "  jumpUrl=bannerADlink[adNum];"
showpicc = showpicc &  "   jumpTarget='_blank';"
showpicc = showpicc &  "   if (jumpUrl != ''){"
showpicc = showpicc &  "      if (jumpTarget != '')window.open(jumpUrl,jumpTarget);"
showpicc = showpicc &  "     else location.href=jumpUrl;"
showpicc = showpicc &  "   }"
showpicc = showpicc &  "}"
showpicc = showpicc &  "function displayStatusMsg() {"
showpicc = showpicc &  "   status=bannerADlink[adNum];"
showpicc = showpicc &  "   document.returnValue = true;"
showpicc = showpicc &  "}"
showpicc = showpicc &  "</SCRIPT>"

showpicc = showpicc &  "<TABLE cellSpacing='0' cellPadding='0' width='" & ImgWidth +20 & "' border='0'><TR height='10'><TD width='10' background='images/bg_0ltop.gif'></TD><TD width='" & ImgWidth & "' background='images/bg_01.gif'></TD><TD width='10' background='images/bg_0rtop.gif'></TD></TR><TR height='" & ImgHeight & "'><TD width='10' background='images/bg_03.gif'></TD><TD width='" & ImgWidth & "' valign='top'>"
showpicc =  showpicc & AD_title
showpicc =  showpicc & "</TD><TD width='10' background='images/bg_04.gif'></TD></TR><TR height='10'><TD width='10' background='images/bg_0lbottom.gif'></TD><TD width='" & ImgWidth & "' background='images/bg_02.gif'></TD><TD width='10' background='images/bg_0rbottom.gif'></TD></TR>"
showpicc =  showpicc & "<TR><TD id='title' colspan='3' align='center'>"
showpicc =  showpicc & "</TD></TR></TABLE>"
showpicc = showpicc & "<SCRIPT language=javascript>title.innerHTML=""<A href="" +bannerADlink[0] + "">"" + bannerADtitle[0] +""</a>"";setTimeout(""nextAd()"", 3000);//nextAd()</SCRIPT>"
end if
rsPic.close
ShowPicArticle1=showpicc

end Function

sub GetPicArticleTitle1(intTitleLen,intImgWidth,intImgHeight,i)
dim FileType,TitleStr
FileType=right(lcase(rsPic("DefaultPicUrl")),3)
TitleStr=gotTopic(rsPic("Title"),intTitleLen)
strPic=strPic & "bannerADlink[" & cStr(i) & "]=""" & rsPic("LayoutFileName") & "?ArticleID=" & rsPic("ArticleID") & """;" & vbcrlf
if fileType="jpg" or fileType="bmp" or fileType="png" or fileType="gif" then
  strPic=strPic & "bannerAD[" & cStr(i) & "]=""" & rsPic("DefaultPicUrl") & """;" & vbcrlf
else
  strPic=strPic & "bannerAD[" & cStr(i) & "]=""images/NoPic2.jpg"";" & vbcrlf
end if
strPic=strPic & "bannerADtitle[" & cStr(i) & "]=""" & TitleStr & """;" & vbcrlf
end sub

第二步,找到index.asp文件,打开后将(大约是14行)TempStr = Replace(TempStr,"{$ShowPicArticle1}",ShowPicArticle(0,1,20,1,1,120,90,200,false,false))这个代码换成

TempStr = Replace(TempStr,"{$ShowPicArticle}",ShowPicArticle1(0,8,24,160,120,false,false))

第三步,进入后台,点网站模板管理,找到分页面模板(page_index),点后面的界面风格,在代码里面找到{$ShowPicArticle1}将其替换成{$ShowPicArticle}然后点修改,再点更新服务器缓存 就搞定。

第四步,找到Article_Index.asp文件,用fp或dw打开后,把(大约在16行左右)TempStr = Replace(TempStr,"{$ShowPicArticle}",ShowPicArticle(0,1,12,1,1,100,75,200,false,false))改为

TempStr = Replace(TempStr,"{$ShowPicArticle}",ShowPicArticle1(0,8,24,160,120,false,false))

就这样完全搞定。现在你打开自己的首页或是文章频道页看看,是不是全都有图文幻灯片效果了啊?

 


  • 上一篇文章:

  • 下一篇文章: