公告板
 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 | 閱讀: 2148 | 列印 | 文件 | 轉發
 收入網摘
FF [ 2006-04-19 08:31 | 回覆 | 編輯 刪除 ]
真好~ 可是我最近都么时间去修改~唉 555555
nnickk [ 2006-04-18 13:41 | 回覆 | 編輯 刪除 ]
[quote=FF]好好好呢~~ 上次看到谁那里只有静态的改法~~ hoho看到动态的咯~ 晚上争取把它加上![/quote] 動態是我看wbc的方式修改的, 所以目前看到的動態改法, 應該都是從我這邊流出去的...^^
FF [ 2006-04-18 11:56 | 回覆 | 編輯 刪除 ]
好好好呢~~ 上次看到谁那里只有静态的改法~~ hoho看到动态的咯~ 晚上争取把它加上!
nnickk [ 2006-04-17 14:52 | 回覆 | 編輯 刪除 ]
[quote=按下快乐键]静态和动态有什么区别? 我该使用静态还是动态? 请老大赐教,谢谢[/quote] 看你的日誌是靜態輸出還動態的呀...
按下快乐键 [ 2006-04-17 10:35 | 回覆 | 編輯 刪除 ]
静态和动态有什么区别? 我该使用静态还是动态? 请老大赐教,谢谢
nnickk [ 2006-04-14 00:06 | 回覆 | 編輯 刪除 ]
[quote=beau]大大 你我都是用動態的 雖然隨機日誌有成功 但是左下角有出現網頁發生錯誤的訊息 你我的都是一樣的情形喔 http://blog.bodhi.tw[/quote] 你說的錯誤訊息在哪呀??
nnickk [ 2006-04-13 15:16 | 回覆 | 編輯 刪除 ]
[quote=vivipa]大大,如果显示10条 怎么改?谢谢[/quote]
CODE:

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; o&#114;der by Rnd(-(log_id+&#34;&Rnd()&&#34;))&#34;)
改成
CODE:

Set RsT=conn.execute(&#34;Sel&#101;ct TOP 10 log_Title,log_id,log_ViewNums from blog_Content wh&#101;re log_ID<>&#34;&id&&#34; o&#114;der by Rnd(-(log_id+&#34;&Rnd()&&#34;))&#34;)
也就是把5換成10
vivipa [ 2006-04-13 15:09 | 回覆 | 編輯 刪除 ]
大大,如果显示10条 怎么改?谢谢
nnickk [ 2006-04-13 14:50 | 回覆 | 編輯 刪除 ]
[quote=beau]如果你開啟一個日誌 在 IE 左下角會出現一個黃色三角形 裡頭有一個驚嘆號 你只要用滑鼠點那個三角形兩下 就可以看到錯誤訊息嚕 我看到的錯愈訊息是這樣 你跟我都是一樣的錯誤訊息 行: 173 字元: 1 錯誤: 'document.getElementById(......)' 是 null 或不是一個物件 程式碼: 0 URL: http://nnickk.com/blog/article.asp?id=167[/quote] 哦! 太久沒用IE了。 一行忘記刪掉,
CODE:

response.Write &#34;<script>document.getElementById('wbc_tag').innerHTML='&#34;&OutPut&&#34;'</script>&#34;
把這一行刪掉就好了。
beau [ 2006-04-13 14:32 網址 | 回覆 | 編輯 刪除 ]
如果你開啟一個日誌 在 IE 左下角會出現一個黃色三角形 裡頭有一個驚嘆號 你只要用滑鼠點那個三角形兩下 就可以看到錯誤訊息嚕 我看到的錯愈訊息是這樣 你跟我都是一樣的錯誤訊息 行: 173 字元: 1 錯誤: 'document.getElementById(......)' 是 null 或不是一個物件 程式碼: 0 URL: http://nnickk.com/blog/article.asp?id=167
發表評論
暱 稱: 密 碼:
網 址: E - mail:
驗證碼: 驗證碼圖片 選 項:
頭 像:
內 容: