海外邮件中继,海外退信中继,美国高速VPS,不限流量VPN,邮局维护和管理,邮件网关,EMOS邮件中继,POSTFIX邮件中继,Winwebmail邮件中继,Winmail邮件中继,DBMail邮件中继,JDMail邮件中继,Exchange邮件中继,MDaemon邮件中继 淘宝店:http://shantan.taobao.com 云邮科技官网:www.yunrelay.com
【字体设置:大 中 小】
今天参考其他网站代码,终于成功添加了TAGS功能,以下是添加方法:
1.在include/function.asp最后的%>前面加上下面代码
'显示TAG
Function ShowTag(blogID,TagMode)
sql="select TagsName,Blog_ID from blog_tag where blog_id="&blogID&""
DIM STAG,STARR,STNUM,STI,taglist
Set STAG=SERVER.CREATEOBJECT("ADODB.RECORDSET")
STAG.OPEN sql,conn,1,1
IF STAG.EOF AND STAG.BOF THEN
Else
STARR=STAG.GetRows
STNUM=Ubound(STARR,2)
For STI=0 To STNUM
IF TagMode="Edit" then
IF STI=STNUM Then
ShowTag=ShowTag&STARR(0,STI)
Else
ShowTag=ShowTag&STARR(0,STI)&";"
End IF
Else
IF ucase(Trim(CheckStr(Trim(Request.QueryString("tags")))))=ucase(Trim(STARR(0,STI))) Then
taglist="<font color=#ff0000>"&STARR(0,STI)&"</font>"
Else
taglist=STARR(0,STI)
End IF
IF STI=STNUM Then
ShowTag=ShowTag&"<a href=""blogtag.asp?tags="&Server.URLEncode(STARR(0,STI))&""">"&taglist&"</a>"
Else
ShowTag=ShowTag&"<a href=""blogtag.asp?tags="&Server.URLEncode(STARR(0,STI))&""">"&taglist&"</a>"&" | "
End IF
End IF
Next
IF TagMode="Edit" then
Else
ShowTag = "<b>Tag : "&ShowTag&"</b>"
End IF
END IF
STAG.CLOSE
SET STAG=NOTHING
End Function
Sub EditTags(log_ID)
SQL="Select * from blog_tag where blog_id="&log_ID&""
Set deltag=Server.CreateObject("Adodb.Recordset")
deltag.OPEN SQL,CONN,1,1
DO While NOT deltag.Eof
conn.execute ("update blog_tags set TagBlogCount=TagBlogCount-1 where TagName='"&deltag("TagsName")&"'")
deltag.MoveNext
LOOP
deltag.Close
set deltag=nothing
conn.execute ("Delete * from blog_tag where blog_ID="&log_ID&"")
conn.execute ("Delete * from blog_tags where TagBlogCount=0")
End Sub
'显示TAGS分类
Sub TagsList(tMode)
Dim TagRS,MAXTag
IF tMode="Hot" Then
Sql="Select TOP 20 * from blog_tags order by TagBlogCount desc, CreateDate asc"
Else
Sql="Select * from blog_tags order by CreateDate desc"
End IF
Set TagRS = Server.CreateObject("Adodb.RecordSet")
TagRS.Open Sql,Conn,1,1
IF TagRS.Eof AND TagRS.Bof Then
Response.Write ("目前没有 Tags 分类。")
Else
'得到当前最多日志分类数
MAXTag=conn.Execute("select top 1 TagBlogCount From Blog_Tags Order By TagBlogCount Desc")(0)
Do While Not TagRS.Eof
IF TagRS("TagBlogCount")>=cint(MAXTag*0.2) AND TagRS("TagBlogCount")<=cint(MAXTag*0.6) Then
Response.Write ("<a href=""blogtag.asp?tags="&Server.URLEncode(TagRS("TagName"))&"""><span class=""Tagg"" title='此Tag共有"&TagRS("TagBlogCount")&"篇日志'>" & TagRS("TagName") & "</span></a>")
ElseIF TagRS("TagBlogCount")>cint(MAXTag*0.6) AND TagRS("TagBlogCount")<=cint(MAXTag*0.9) Then
Response.Write ("<a href=""blogtag.asp?tags="&Server.URLEncode(TagRS("TagName"))&"""><span class=""Tagg"" title='此Tag共有"&TagRS("TagBlogCount")&"篇日志'>" & TagRS("TagName") & "</span></a>")
ElseIF TagRS("TagBlogCount")>cint(MAXTag*0.9) Then
Response.Write ("<a href=""blogtag.asp?tags="&Server.URLEncode(TagRS("TagName"))&"""><span class=""Tagg"" title='此Tag共有"&TagRS("TagBlogCount")&"篇日志'>" & TagRS("TagName") & "</span></a>")
Else
Response.Write ("<a href=""blogtag.asp?tags="&Server.URLEncode(TagRS("TagName"))&"""><span class=""Tagg"" title='此Tag共有"&TagRS("TagBlogCount")&"篇日志'>" & TagRS("TagName") & "</span></a>")
End IF
Response.Write (" | ")
TagRS.MoveNext
Loop
End IF
TagRS.Close
Set TagRS=NoThing
End Sub
Sub DelTags(blog_ED)
SQL="Select * from blog_tag where blog_id="&blog_ED&""
Set deltag=Server.CreateObject("Adodb.Recordset")
deltag.OPEN SQL,CONN,1,1
DO While NOT deltag.Eof
conn.execute ("update blog_tags set TagBlogCount=TagBlogCount-1 where TagName='"&deltag("TagsName")&"'")
deltag.MoveNext
LOOP
deltag.Close
set deltag=nothing
conn.execute ("Delete * from blog_tag where blog_ID="&blog_ED&"")
conn.execute ("Delete * from blog_tags where TagBlogCount=0")
End Sub
2.把TAG.MDB的两个表导出你的数据库,当然只导出定义...
3.在你的blogpost.asp里加上这样一句话,
<tr bgcolor="#FFFFFF">
<td align="right"><b>Tags:</b></td>
<td td colspan="2"><input name="log_Tags" type="text" id="log_Tags" size="50"> 最多5个Tag 用;分隔</td>
</tr>
在那个定义的dim Log_Title,log_Content的最后加上 ,log_tags 还要在
log_Weather=Request.Form("log_Weather")的后面加上 log_tags=Request.Form("log_tags")然后还是在blogpost.asp里的找到这样一句话 SQLQueryNums=SQLQueryNums+4
在他的上面添加
'处理TAG信息
if trim(log_tags)<>empty then
log_tags=Split(log_tags,";")
Dim tabs,ts
For tabs=0 to Ubound(log_tags)
Sql="Select TagName from blog_tags where TagName='"&log_tags(tabs)&"'"
Set ts=Server.CreateObject("Adodb.Recordset")
ts.open sql,conn,1,1
If ts.eof and ts.bof then
conn.execute ("insert into blog_tags(TagName) values('"&log_tags(tabs)&"')")
Else
conn.execute ("update blog_tags set TagBlogCount=TagBlogCount+1 where tagName='"&log_tags(tabs)&"'")
End If
conn.execute ("insert into blog_tag(blog_id,tagsName) values("&PostLogID&",'"&log_tags(tabs)&"')")
ts.close
Set ts=Nothing
Next
End IF
'TAG信息处理结束
4.打开blogedit.asp
和blogpost一样也是添加
<tr bgcolor="#FFFFFF">
<td align="right"><b>Tags:</b></td>
<td td colspan="2"><input name="log_Tags" type="text" id="log_Tags" size="50" value="<%=ShowTag(blog_Edit("log_ID"),"Edit")%>"> 最多5个Tag 用;分隔</td>
</tr>
找到 Conn.ExeCute("UPDATE blog_Info SET blog_LogNums=blog_LogNums-1") 这样一句话后面加上
call DelTags(blog_ED)
找到dim Log_Title,log_Content,在这个定义的最后面加上 ,log_tags 和blogpost.asp添加一样
找到
Conn.ExeCute("UPDATE blog_Content Set log_Title='"&log_Title&"', .......[code]行后面加上
[code]log_tags=Request.Form("log_tags")
找到 Response.Write("<br><br>修改日志成功!<br> 这句话 在他的上面添加
'处理TAG信息
Dim tabs,ts,deltag
'为了保证数据的统计的准确,先删除此日志以前的TAG并将该TAG的日志数减1
Call EditTags(log_ID)
'加入新的TAGS
if trim(log_tags)<>empty then
log_tags=Split(log_tags,";")
For tabs=0 to Ubound(log_tags)
Sql="Select TagName from blog_tags where TagName='"&log_tags(tabs)&"'"
Set ts=Server.CreateObject("Adodb.Recordset")
ts.Open sql,conn,1,1
IF ts.Eof AND ts.Bof Then
conn.execute ("Insert Into blog_tags(TagName) Values('"&log_tags(tabs)&"')")
Else
'问题:如果日志此标签存在,可以加上,但是,如果以前已经使用了此标签,统计数就会多1。
conn.Execute ("Update blog_tags Set TagBlogCount=TagBlogCount+1 where tagName='"&log_tags(tabs)&"'")
End If
conn.Execute ("Insert Into blog_tag(blog_id,tagsName) Values("&log_ID&",'"&log_tags(tabs)&"')")
ts.Close
Set ts=Nothing
Next
End IF
'TAG信息处理结束
5.在default.asp找到
Response.Write("<br>")
If HtmlEncode(webLog("log_Content"))<>log_Intro Then Response.Write(log_ShowURL&"<img src=""images/icon_readmore.gif"" align=""absmiddle"" border=""0""> 阅读全文.........</a>")
在后面加上
'显示TAGS
if ShowTag(weblog_ID,"Show")<>empty then
Response.Write (ShowTag(weblog_ID,"Show"))
Response.Write("<br>")
end if
'显示TAGS结束
对了blogtag.asp里面还要用到个分页的函数
Function MultiPage_l(Numbers,Perpage,Curpage,Url_Add) '列表分页函数
CurPage=Int(Curpage)
Dim URL
URL=Request.ServerVariables("Script_Name")&Url_Add
MultiPage_l=""
Dim Page,Offset,PageI
If Int(Numbers)>Int(PerPage) Then
Page=10
Offset=2
Dim Pages,FromPage,ToPage
If Numbers Mod Cint(Perpage)=0 Then
Pages=Int(Numbers/Perpage)
Else
Pages=Int(Numbers/Perpage)+1
End If
FromPage=Curpage-Offset
ToPage=Curpage+Page-Offset-1
If Page>Pages Then
FromPage=1
ToPage=Pages
Else
If FromPage<1 Then
Topage=Curpage+1-FromPage
FromPage=1
If (ToPage-FromPage)<Page And (ToPage-FromPage)<Pages Then ToPage=Page
ElseIF Topage>Pages Then
FromPage =Curpage-Pages +ToPage
ToPage=Pages
If (ToPage-FromPage)<Page And (ToPage-FromPage)<Pages Then FromPage=Pages-Page+1
End If
End If
MultiPage_l="<a href="""&Url&"sortBy="&sortBy&"&page=1""><img src=""images/icon_ar.gif"" border=""0"" align=""absmiddle""></a> "
For PageI=FromPage TO ToPage
If PageI<>CurPage Then
MultiPage_l=MultiPage_l&"<a href="""&Url&"sortBy="&sortBy&"&page="&PageI&""">["&PageI&"]</a> "
Else
MultiPage_l=MultiPage_l&"<b>["&PageI&"]</b> "
End If
Next
If Int(Pages)>Int(Page) Then
MultiPage_l=MultiPage_l&" ... <a href="""&Url&"page="&Pages&"""> ["&pages&"] <img src=""images/icon_al.gif"" border=""0"" align=""absmiddle""></a> <input type=""text"" name=""custompage"" size=""1"" class=""custompage"" onKeyDown=""javascript: if(window.event.keyCode == 13) window.location='"&Url&"page='+this.value;"">"
Else
MultiPage_l=MultiPage_l&" <a href="""&Url&"sortBy="&sortBy&"&page="&Pages&"""><img src=""images/icon_al.gif"" border=""0"" align=""absmiddle""></a>"
End If
End If
End Function
点击下载此文件
发表评论 - 不要忘了输入验证码哦!