建博的时候,发现Zblog只能搜索站内,无法使用百度和谷歌的站内搜索,决定自己动手加一个,找了N久没有找到相关的文章,也没有插件,在百度的官网上找到了站内搜索的代码,网上也有不少,但无法直接使用,咋办来,自己动手吧,下面是步聚,对于不同的版本和主题可能会有所差异,应该不大,动手前记得做备份哟.

先看一下效果:

 

第一步:打开主目录下cmd.asp,在里面搜索:Function Search(),大约在907行,原代码如下:
 

折叠展开XML/HTML Code
Function Search()  
 
'plugin node  
For Each sAction_Plugin_Search_Begin in Action_Plugin_Search_Begin  
If Not IsEmpty(sAction_Plugin_Search_Begin) Then Call Execute(sAction_Plugin_Search_Begin)  
If bAction_Plugin_Search_Begin=True Then Exit Function  
Next  
RedirectBy301(ZC_BLOG_HOST & "search.asp?q=" & Server.URLEncode(Request.Form("edtSearch")))   
End Function  
 


改为:

折叠展开XML/HTML Code
Function Search()  
 
'plugin node  
For Each sAction_Plugin_Search_Begin in Action_Plugin_Search_Begin  
If Not IsEmpty(sAction_Plugin_Search_Begin) Then Call Execute(sAction_Plugin_Search_Begin)  
If bAction_Plugin_Search_Begin=True Then Exit Function  
Next  
dim s  
s=Request("s")  
if s=3 then  
RedirectBy301(ZC_BLOG_HOST & "search.asp?q=" & Server.URLEncode(Request.Form("edtSearch")))   
else if s=1 then  
RedirectBy301("http://www.baidu.com/s?cl=3ct=2097152tn=baidulocalsi=www.qihow.com/blogwd=" & Server.URLEncode(Request.Form("edtsearch")))  
else  
RedirectBy301("http://www.google.cn/search?hl=zh-CNie=UTF-8newwindow=1sitesearch=www.qihow.com/blogq=" & Server.URLEncode(Request.Form("edtsearch")))  
end if  
end if  
End Function  
 

[NextPage]第二步:修改模版文件中的搜索功能,首先找到搜索功能的代码,以<form action="<#ZC_BLOG_HOST#>cmd.asp?act=Search" accept-charset="UTF-8" method="post" id="search-theme-form">开头,以</form>结束的地方,在</form>之前,添加如下代码:

折叠展开XML/HTML Code
<input name=s type=radio value="1" checked> 百度  
<input name=s type=radio value="2">Google  
<input name=s type=radio value="3">站内 

重建文件,看一下可以了吗?其它页面有搜索功能的,按第二步改搜索代即可.

直接下载下面的CMD文件,解压到网站根目录,复盖,用DW等编辑软件打开,找到第919行和第921行,将里面的网址改为你自己的网址即可.记住不要带http://.

cmd.rar

演示:  http://www.qihow.com/blog


 



原创文章如转载,请注明:转载自郑州网站优化,seo推广方案策划培训-翼虎seo学习博客
原文地址:http://www.qihow.com/blog/wangluo/102.html