2008年06月28日
百度了半天,终于给我的Blog加上了相关日志功能
修改说明:
打开文件:classcls_article.asp
1.查找下面内容
TempArticle=Replace(TempArticle,"<$log_ViewNums$>",log_ViewArr(4,0))
在此内容下增加一行,复制以下代码
'*********** 相关日志功能 修改1 BY HAYDEN *********
TempArticle=Replace(TempArticle,"<$log_relatedtag$>",getRelated(log_ViewArr(8,0),LogID))
'************ 相关日志功能 修改1 END ************
TempArticle=Replace(TempArticle,"<$log_relatedtag$>",getRelated(log_ViewArr(8,0),LogID))
'************ 相关日志功能 修改1 END ************
2.继续…查找
dim getTag
换行 在下面添加
'*********** 相关日志功能 修改2 BY HAYDEN ***********
Dim haydenTags : haydenTags = log_ViewArr(19,0)
'*********** 相关日志功能 修改2 **********
Dim haydenTags : haydenTags = log_ViewArr(19,0)
'*********** 相关日志功能 修改2 **********
3.继续..查找
<img src="/images/tag.gif" style="margin:4px 2px -4px 0px" alt=""/><strong>Tags:</strong> <%=getTag.filterHTML(log_ViewArr(19,0))%><br/>
换行 在下面添加
'*********** 相关日志功能 修改3 BY HAYDEN ***********
<img src="/images/search.gif" style="margin:4px 2px -4px 0px" alt=""/><strong>相关日志:</strong><%=getRelated(haydenTags,LogID)%><br/>
'********** 相关日志功能 修改3 END ***********
<img src="/images/search.gif" style="margin:4px 2px -4px 0px" alt=""/><strong>相关日志:</strong><%=getRelated(haydenTags,LogID)%><br/>
'********** 相关日志功能 修改3 END ***********
4.继续 滑到文件底部 在最后一个 %> 这个符号前加入下面这段代码
'********************************
' 显示相关日志
' 作者:静¢脉
' 出自:myhhe.cn
' 时间:2007.11.25
'********************************
Function getRelated(hayden_tag,hayden_LogID)
getRelated=""
Dim i,RsT,OutPut
Dim hayden_arr_tag
Dim hayden_sql
Dim hayden_sqlTag : hayden_sqlTag=""
OutPut=""
if hayden_tag<>"" Then
hayden_arr_tag=split(hayden_tag,"{")
For i = 1 to Ubound(hayden_arr_tag)
If i > 1 Then hayden_sqlTag=hayden_sqlTag & " or "
hayden_sqlTag = hayden_sqlTag & "log_tag like '%{" & hayden_arr_tag(i) & "%' "
Next
hayden_sql="Select top 10 log_Title,log_id,log_ViewNums from blog_Content where (" & hayden_sqlTag & ") and log_ID<>" & hayden_LogID & " and log_IsDraft=False and log_CateID not in (select cate_id from blog_Category where cate_secret=True ) order by log_PostTime desc"
'此处红色标记处,感谢 ppcode 提出指正 #2007-11-26
Set RsT=conn.execute(hayden_sql)
if not RsT.eof then
Do until Rst.eof
OutPut=OutPut&"<font face='Wingdings'>n</font> <a href='article.asp?id="&RsT(1)&"' target='_blank'>"&RsT(0)&"["&RsT(2)&"]</a><br>"
Rst.movenext
Loop
End if
End if
If OutPut="" Then
OutPut="无相关日志"
Else
OutPut="<div class='Content-body' id='hayden_tag'>"&Replace(OutPut,chr(39),chr(34))&"</div>"
'注意上面DIV中的class名称,如果想给他设定单独的样式,可以在这里给他另定一个名称
End If
getRelated=OutPut
Set rst=nothing
End Function
'******** 相关日志功能 getRelated END BY HAYDEN **********
' 显示相关日志
' 作者:静¢脉
' 出自:myhhe.cn
' 时间:2007.11.25
'********************************
Function getRelated(hayden_tag,hayden_LogID)
getRelated=""
Dim i,RsT,OutPut
Dim hayden_arr_tag
Dim hayden_sql
Dim hayden_sqlTag : hayden_sqlTag=""
OutPut=""
if hayden_tag<>"" Then
hayden_arr_tag=split(hayden_tag,"{")
For i = 1 to Ubound(hayden_arr_tag)
If i > 1 Then hayden_sqlTag=hayden_sqlTag & " or "
hayden_sqlTag = hayden_sqlTag & "log_tag like '%{" & hayden_arr_tag(i) & "%' "
Next
hayden_sql="Select top 10 log_Title,log_id,log_ViewNums from blog_Content where (" & hayden_sqlTag & ") and log_ID<>" & hayden_LogID & " and log_IsDraft=False and log_CateID not in (select cate_id from blog_Category where cate_secret=True ) order by log_PostTime desc"
'此处红色标记处,感谢 ppcode 提出指正 #2007-11-26
Set RsT=conn.execute(hayden_sql)
if not RsT.eof then
Do until Rst.eof
OutPut=OutPut&"<font face='Wingdings'>n</font> <a href='article.asp?id="&RsT(1)&"' target='_blank'>"&RsT(0)&"["&RsT(2)&"]</a><br>"
Rst.movenext
Loop
End if
End if
If OutPut="" Then
OutPut="无相关日志"
Else
OutPut="<div class='Content-body' id='hayden_tag'>"&Replace(OutPut,chr(39),chr(34))&"</div>"
'注意上面DIV中的class名称,如果想给他设定单独的样式,可以在这里给他另定一个名称
End If
getRelated=OutPut
Set rst=nothing
End Function
'******** 相关日志功能 getRelated END BY HAYDEN **********
5.打开文件:article.asp
查找:
log_DisComment FROM
修改成:
log_DisComment,log_tag FROM
打开文件:TemplateArticle.asp
查找:
<$log_tag$><br/>
换行 在下面添加:
<img src="/images/search.gif" style="margin:4px 2px -4px 0px" alt=""/><strong>相关日志:</strong> <$log_relatedtag$><br/>
最后去后台
重建数据缓存
重新统计网站数据
重新生成所有日志到文件
重新建立日志索引
转载本站文章请注明,转载自:LeNgHoSt的小窝[http://www.lenghost.cn] 本文链接: http://www.lenghost.cn/site-news/add-related-post-to-pjblog/

发表评论