公告板
 2007-01-18網址變更,請使用新網址瀏覽網站。http://blog.nnickk.com/
 2007-01-17有任何問題歡迎到留言板留言!
 廣告一則電腦桌椅專賣店,另有辦公桌椅、家具、寢具等您來挑...

PJBlog-2.5-增加隨機相關日誌連結

注意:根據wbc的改法,應該是針對靜態日誌而已,下面已經有針對動態日誌的改法,兩者只能選擇其一。

靜態日誌改法:無隨機
1 打開 主目錄的 article.asp

找到最後一行


在其 上面 加入如下代碼
CODE:


  <%

  Dim wbc_tag,Rs,i,RsT,OutPut

  Set Rs=conn.execute(&#34;Sel&#101;ct * from blog_Content wh&#101;re log_ID=&#34;&id&&#34;&#34;)

  OutPut=&#34;&#34;

  if not rs.eof then

     wbc_tag=rs(&#34;log_tag&#34;)

     if wbc_tag<>&#34;&#34; then

        wbc_tag=split(wbc_tag,&#34;}&#34;)

                i=0

                DO until i>Ubound(wbc_tag)

           Set RsT=conn.execute(&#34;Sel&#101;ct log_Title,log_id,log_ViewNums from  blog_Content wh&#101;re log_tag like '%&#34;&wbc_tag(i)&&#34;}%' and log_ID<>&#34;&id&&#34; o&#114;der by log_PostTime desc&#34;)

                   if not RsT.eof then

                      Do until Rst.eof

                                  If instr(OutPut,RsT(0))=0 and wbc_tag(i)<>&#34;&#34; then

                                         OutPut=OutPut&&#34;   <font face='Wingdings'>n</font> <a href='article.asp?id=&#34;&RsT(1)&&#34;'>&#34;&RsT(0)&&#34;[&#34;&RsT(2)&&#34;]</a>
&#34;

                                  End if

                                  Rst.movenext

                          Loop

                   End if

                   i=i+1

                Loop

         End if

  End if

  OutPut=replace(OutPut,chr(39),chr(34))

  response.Write &#34;<script>document.getElementById('wbc_tag').innerHTML='&#34;&OutPut&&#34;'</script>&#34;

  Set rs=nothing

  %>



2 打開 Template 目錄下的 Article.asp 文件

找到 (29行左右)
""/Tags: <$log_tag$>


在後面添加
CODE:


<img src=&#34;images/tag.gif&#34; style=&#34;margin:4px 2px -4px 0px&#34; alt=&#34;&#34;/><strong>相關日誌:</strong>


<div class=&#34;Content-body&#34; id=&#34;wbc_tag&#34;></div>




進入Blog的管理頁面---站點基本設置---初始化数据----重新生成所有日志到文件
確定

資料來源:wbc


---------------------------------------------------------------------------------------------------

動態日誌改法
打開 class的 cls_article.asp

找到這一行
CODE:


<img src=&#34;images/tag.gif&#34; style=&#34;margin:4px 2px -4px 0px&#34; alt=&#34;&#34;/><strong>Tags:</strong> <%=getTag.filterHTML(log_ViewArr(19,0))%>




在其 後面 加入如下代碼
CODE:


<!--相關日誌-->

  <%

  Dim wbc_tag,nnickk_tag,Rs,i,RsT,OutPut

  Set Rs=conn.execute(&#34;Sel&#101;ct * from blog_Content wh&#101;re log_ID=&#34;&id&&#34;&#34;)

  OutPut=&#34;&#34;

  if not rs.eof then

     wbc_tag=rs(&#34;log_tag&#34;)

     if wbc_tag<>empty then

         wbc_tag=replace(wbc_tag,&#34;{&#34;,&#34;&#34;)

        wbc_tag=split(wbc_tag,&#34;}&#34;)

            i=0

            DO until i>Ubound(wbc_tag)

            

                nnickk_tag=&#34;&#34;

                if wbc_tag(i)<>empty then

                  Set Rs=conn.execute(&#34;Sel&#101;ct * from blog_tag wh&#101;re tag_ID=&#34;&wbc_tag(i)&&#34;&#34;)

                  if not rs.eof then

                     nnickk_tag=rs(&#34;tag_name&#34;)

                  end if

                end if

                

               Randomize

               Set RsT=conn.execute(&#34;Sel&#101;ct TOP 5 log_Title,log_id,log_ViewNums from  blog_Content wh&#101;re log_isdraft<>-1 and (log_tag like '%&#34;&wbc_tag(i)&&#34;%' o&#114; log_title like '%&#34;&nnickk_tag&&#34;%') and log_ID<>&#34;&id&&#34; o&#114;der by Rnd(-(log_id+&#34;&Rnd()&&#34;))&#34;)

               if not RsT.eof then

                  Do until Rst.eof

                      If instr(OutPut,RsT(0))=0 and wbc_tag(i)<>&#34;&#34; then

                             OutPut=OutPut&&#34;  <font face='Wingdings'>n</font> <a href='article.asp?id=&#34;&RsT(1)&&#34;'>&#34;&RsT(0)&&#34;[&#34;&RsT(2)&&#34;]</a>
&#34;

                      End if

                      Rst.movenext

                  Loop

               End if

               i=i+1

             Loop

         End if

          

        if output=&#34;&#34; then

           Randomize

           Set RsT=conn.execute(&#34;Sel&#101;ct TOP 5 log_Title,log_id,log_ViewNums from blog_Content wh&#101;re log_ID<>&#34;&id&&#34; and log_isdraft<>-1 o&#114;der by Rnd(-(log_id+&#34;&Rnd()&&#34;))&#34;)

                   if not RsT.eof then

                      Do until Rst.eof

                          If instr(OutPut,RsT(0))=0 then

                                 OutPut=OutPut&&#34;  <font face='Wingdings'>n</font> <a href='article.asp?id=&#34;&RsT(1)&&#34;'>&#34;&RsT(0)&&#34;[&#34;&RsT(2)&&#34;]</a>
&#34;

                          End if

                          Rst.movenext

                      Loop

                   End if

        end if

  End if

  OutPut=replace(OutPut,chr(39),chr(34))

  Set rs=nothing

  %>

                            <img src=&#34;images/tag.gif&#34; style=&#34;margin:4px 2px -4px 0px&#34; alt=&#34;&#34;/><strong>相關日誌:</strong>


<%=OutPut%>

<div class=&#34;Content-body&#34; id=&#34;wbc_tag&#34;></div>


<!--/相關日誌-->



這樣就可以了,
相關日誌取樣規則,
每個tag隨機選取五則相關的日誌標題或日誌tag。
-----------------------------------------------
果真我還是很懶,
一百多篇,改tag會改到手軟,
修改為無tag自動隨機挑五則。
引用通告地址: 點擊獲取引用地址
標籤:  pjblog
評論: 24 | 引用: 0 | 閱讀: 2055 | 列印 | 文件 | 轉發
 收入網摘
FF [ 2006-04-20 00:55 | 回覆 | 編輯 刪除 ]
好像也有只有一个的
nnickk [ 2006-04-19 16:39 | 回覆 | 編輯 刪除 ]
[quote=FF]我都设了tag的.[/quote] 不懂你的意思。 --------- 動態版相關日誌取樣規則, 每個tag隨機選取五則相關的日誌標題或日誌tag。 若無tag自動隨機挑五則。
FF [ 2006-04-19 15:56 | 回覆 | 編輯 刪除 ]
我都设了tag的.
nnickk [ 2006-04-19 14:31 | 回覆 | 編輯 刪除 ]
[quote=FF]好像也有只有一个的[/quote] 有設tag,他就只會抓相關的tag跟標題, 所以只有一個相關就只會出現一則...
nnickk [ 2006-04-19 09:30 | 回覆 | 編輯 刪除 ]
[quote=FF]好像似乎 不是按照tag来的[/quote] 有設tag,他就會去比對有沒有相關的tag, 或者標題有沒有tag裡的關鍵字, 沒設tag就會隨機抓五則...
nnickk [ 2006-04-19 09:28 | 回覆 | 編輯 刪除 ]
[quote=FF]那个 n 怎么去掉啊 [/quote] n?? 什麼n呀...
nnickk [ 2006-04-19 09:26 | 回覆 | 編輯 刪除 ]
[quote=FF]动态只要改一个页面就可以了?[/quote] 是的, 動態只要修改class的 cls_article.asp
FF [ 2006-04-19 08:43 | 回覆 | 編輯 刪除 ]
好像似乎 不是按照tag来的
FF [ 2006-04-19 08:41 | 回覆 | 編輯 刪除 ]
那个 n 怎么去掉啊
FF [ 2006-04-19 08:32 | 回覆 | 編輯 刪除 ]
动态只要改一个页面就可以了?
發表評論
暱 稱: 密 碼:
網 址: E - mail:
驗證碼: 驗證碼圖片 選 項:
頭 像:
內 容: