
提供日期右对齐、标题稿纸效果等! 351
将下面的过程相应替换即可。
下面的代码有三个功能:
1、让首页的最新内容三天内日期是红色,否则是灰色,天数可以自己改;
2、日期右对齐,绝对你想怎么对就怎么对,适应各种类型网站的需要;
3、标题稿纸效果,你可以选用CSS定义虚线,也可以选用图片作为背景,用CSS当然简单些了,但缺少多样及个性,而背景却要下载图片(图片自己去找,好象有人提供过),但也随心所欲,所以各有所长。
'=================================================
'过程名:ShowNewArticle
'作 用:显示最新文章
'参 数:ArticleNum ----最多显示多少篇文章
' TitleLen ----标题最多字符数,一个汉字=两个英文字符
'=================================================
sub ShowNewArticle(ArticleNum,TitleLen)
dim sqlNew,rsNew
if ArticleNum>0 and ArticleNum<=100 then
sqlNew="select top " & ArticleNum
else
sqlNew="select top 10 "
end if
sqlNew=sqlNew & " A.ArticleID,A.Title,A.Author,A.UpdateTime,A.Hits,L.LayoutFileName from article A inner join Layout L on L.LayoutID=A.LayoutID where A.Deleted=False and A.Passed=True order by A.articleid desc"
Set rsNew= Server.CreateObject("ADODB.Recordset")
rsNew.open sqlNew,conn,1,1
if TitleLen<0 or TitleLen>255 then TitleLen=50
if rsNew.bof and rsNew.eof then
response.write "<img src='skin/1/xiao.gif'>没有文章"
else
do while not rsNew.eof
'--------------------------------稿纸效果修改开始--------这个是用CSS定义的虚线
response.write "<table border=0 width='100%' cellspacing=0 cellpadding=1 ><tr><td>"
response.write "<img src='images/article_common.gif'><a href='" & rsNew("LayoutFileName") & "?ArticleID=" & rsNew("articleid") &"' title='标题:" & rsNew("Title") & vbcrlf & "作者:" & rsNew("Author") & vbcrlf & "时间:" & rsNew("UpdateTime") & vbcrlf & "点击:" & rsNew("Hits") & "' target='_blank'>" & gotTopic(rsNew("title"),TitleLen) & "</a>"
if datediff("d",rsNew("UpdateTime"),date())<3 then
response.write("</td><td align='right' nowrap style='width:1%'><font color=red>" & month(rsnew("updateTime")) & "-" & day(rsnew("updateTime")) & "</font>")
else
response.write("</td><td align='right' nowrap style='width:1%'><font color=#999999>" & month(rsnew("updateTime")) & "-" & day(rsnew("updateTime")) & "</font>")
end if
response.write "</td></tr><tr><td colspan='2'><table width='100%' border=0 cellspacing=0 cellpadding=0 style='height:1; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #cccccc'><tr><td></td></tr></table></td></tr></table>"
'--------------------------------稿纸效果修改结束--------
rsNew.movenext
loop
end if
rsNew.close
set rsNew=nothing
end sub
'=================================================
'过程名:ShowHot
'作 用:显示热门文章
'参 数:ArticleNum ----最多显示多少篇文章
' TitleLen ----标题最多字符数,一个汉字=两个英文字符
'=================================================
sub ShowHot(ArticleNum,TitleLen)
dim sqlHot,rsHot
if ArticleNum>0 and ArticleNum<=100 then
sqlHot="select top " & ArticleNum
else
sqlHot="select top 10 "
end if
sqlHot=sqlHot & " A.ArticleID,A.Title,A.Author,A.UpdateTime,A.Hits,L.LayoutFileName from article A inner join Layout L on L.LayoutID=A.LayoutID where A.Deleted=False and A.Passed=True And A.Hits>=" & HitsOfHot & " order by A.ArticleID desc"
Set rsHot= Server.CreateObject("ADODB.Recordset")
rsHot.open sqlHot,conn,1,1
if TitleLen<0 or TitleLen>255 then TitleLen=50
if rsHot.bof and rsHot.eof then
response.write "<img src='skin/1/xiao.gif'>无热门文章"
else
do while not rsHot.eof
'--------------------------------稿纸效果修改开始--------午夜兰花
response.write "<table border=0 width='100%' cellspacing=0 cellpadding=1><tr><td>"
response.Write "<img src='skin/1/xiao.gif'><a href='" & rsHot("LayoutFileName") & "?ArticleID=" & rsHot("articleid") &"' title='文章标题:" & rsHot("Title") & vbcrlf & "作 者:" & rsHot("Author") & vbcrlf & "更新时间:" & rsHot("UpdateTime") & vbcrlf & "点击次数:" & rsHot("Hits") & "' target='_blank'>" & gotTopic(rsHot("title"),TitleLen) & "</a>[<font color=red>" & rsHot("hits") & "</font>]<br>"
response.write "</td></tr><tr><td><table width='100%' border=0 cellspacing=0 cellpadding=0><tr><td height=1 background='images/bg_dian.gif'></td></tr></table></td></tr></table>"
'--------------------------------稿纸效果修改结束--------午夜兰花
rsHot.movenext
loop
end if
rsHot.close
set rsHot=nothing
end sub
'=================================================
'过程名:ShowElite
'作 用:显示推荐文章
'参 数:ArticleNum ----最多显示多少篇文章
' TitleLen ----标题最多字符数,一个汉字=两个英文字符
'=================================================
sub ShowElite(ArticleNum,TitleLen)
dim sqlElite,rsElite
if ArticleNum>0 and ArticleNum<=100 then
sqlElite="select top " & ArticleNum
else
sqlElite="select top 10 "
end if
sqlElite=sqlElite & " A.ArticleID,A.Title,A.Author,A.UpdateTime,A.Hits,L.LayoutFileName from article A inner join Layout L on L.LayoutID=A.LayoutID where A.Deleted=False and A.Passed=True And A.Elite=True order by A.articleid desc"
Set rsElite= Server.CreateObject("ADODB.Recordset")
rsElite.open sqlElite,conn,1,1
if TitleLen<0 or TitleLen>255 then TitleLen=50
if rsElite.bof and rsElite.eof then
response.write "<img src='skin/1/xiao.gif'>无推荐文章"
else
do while not rsElite.eof
'--------------------------------稿纸效果修改开始--------午夜兰花
response.write "<table border=0 width='100%' cellspacing=0 cellpadding=1><tr><td>"
response.Write "<img src='skin/1/xiao.gif'><a href='" & rsElite("LayoutFileName") & "?ArticleID=" & rsElite("articleid") &"' title='文章标题:" & rsElite("Title") & vbcrlf & "作 者:" & rsElite("Author") & vbcrlf & "更新时间:" & rsElite("UpdateTime") & vbcrlf & "点击次数:" & rsElite("Hits") & "' target='_blank'>" & gotTopic(rsElite("title"),TitleLen) & "</a>[<font color=red>" & rsElite("hits") & "</font>]<br>"
response.write "</td></tr><tr><td><table width='100%' align='center' border=0 cellspacing=0 cellpadding=0><tr><td height=1 background='images/bg_dian.gif'></td></tr></table></td></tr></table>"
'--------------------------------稿纸效果修改结束--------午夜兰花
rsElite.movenext
loop
end if
rsElite.close
set rsElite=nothing
end sub
'=================================================
'过程名:ShowCorrelative
'作 用:显示相关文章
'参 数:ArticleNum ----最多显示多少篇文章
' TitleLen ----标题最多字符数,一个汉字=两个英文字符
'=================================================
sub ShowCorrelative(ArticleNum,TitleLen)
dim rsCorrelative,sqlCorrelative
dim strKey,arrKey,i
if ArticleNum>0 and ArticleNum<=100 then
sqlCorrelative="select top " & ArticleNum
else
sqlCorrelative="Select Top 5 "
end if
strKey=mid(rs("Key"),2,len(rs("Key"))-2)
if instr(strkey,"|")>1 then
arrKey=split(strKey,"|")
strKey="((A.Key like '%|" & arrKey(0) & "|%')"
for i=1 to ubound(arrKey)
strKey=strKey & " or (A.Key like '%|" & arrKey(i) & "|%')"
next
strKey=strKey & ")"
else
strKey="(A.Key like '%|" & strKey & "|%')"
end if
sqlCorrelative=sqlCorrelative & " A.ArticleID,A.Title,A.Author,A.UpdateTime,A.Hits,L.LayoutFileName From Article A inner join Layout L on L.LayoutID=A.LayoutID Where A.Deleted=False and A.Passed=True and " & strKey & " and A.ArticleID<>" & ArticleID & " Order by A.ArticleID desc"
Set rsCorrelative= Server.CreateObject("ADODB.Recordset")
rsCorrelative.open sqlCorrelative,conn,1,1
if TitleLen<0 or TitleLen>255 then TitleLen=50
if rsCorrelative.bof and rsCorrelative.Eof then
response.write "<img src='skin/1/xiao.gif'>没有相关文章"
else
do while not rsCorrelative.eof
'--------------------------------稿纸效果修改开始--------午夜兰花
response.write "<table border=0 width='100%' cellspacing=0 cellpadding=1><tr><td>"
response.write "<img src='skin/1/xiao.gif'><a href='" & rsCorrelative("LayoutFileName") & "?ArticleID=" & rsCorrelative("ArticleID") & "' title='文章标题:" & rsCorrelative("Title") & vbcrlf & "作 者:" & rsCorrelative("Author") & vbcrlf & "更新时间:" & rsCorrelative("UpdateTime") & vbcrlf & "点击次数:" & rsCorrelative("Hits") & "'>" & gotTopic(rsCorrelative("Title"),TitleLen) & "</a><br>"
response.write "</td></tr><tr><td><table width='95%'align='center' border=0 cellspacing=0 cellpadding=0><tr><td height=1 background='images/bg_dian.gif'></td></tr></table></td></tr></table>"
'--------------------------------稿纸效果修改结束--------午夜兰花
rsCorrelative.movenext
loop
end if
rsCorrelative.close
set rsCorrelative=nothing
end sub