7月
6
[原创]打造个性的站点 zblog站内搜索插件
Filed Under 网页设计
1、在自己的网站上新建一个用于显示搜索结果的网页,动态或者静态页面都可以。
2、登录到Google adsense设置adsense,在“产品”那里选择“AdSense for search”。
3、先设置好必要的选项,然后在“更多选项”那一栏,选中“在我的网站上打开搜索结果”并在下面的文本框中输入显示搜索结果的网址,即第一步创建的用于显示搜索结果的网页的URL。
4、在“获取搜索代码”那一栏,将“您的搜索框代码”文本框中生成的代码复制并粘贴到用于显示搜索框的网页的源代码中。
5、将“您的搜索结果代码”文本框中生成的代码复制并粘贴到至用于显示搜索结果的网页的源代码中。
上面是准备工作了,现在正式开始,首先修改search.asp文件,将代码改为如下,其中wx35.cn为你的域名
1 | strQuestion=TransferHTML(Request.QueryString("domains=wx35.cn&q"),"[nohtml]") |
接着修改TEMPLATE目录下search.html文件,插入AdSense for search申请的代码,位置随意,搜索代码和结果代码都要插入,以下是我的示范文件。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <!-- SiteSearch Google --> <form method="get" action="https://www.wx35.cn/search.asp" target="_top"> <table border="0" bgcolor="#F7EFE7"> <tr><td nowrap="nowrap" valign="top" align="left" height="32"> <a href="http://www.google.com/"> <img src="http://www.google.com/logos/Logo_25wht.gif" border="0" alt="Google" align="middle"></img></a> </td> <td nowrap="nowrap"> <input type="hidden" name="domains" value="wx35.cn"></input> <label for="sbi" style="display: none">输入您的搜索字词</label> <input type="text" name="q" size="31" maxlength="255" value="" id="sbi"></input> <label for="sbb" style="display: none">提交搜索表单</label> <input type="submit" name="sa" value="搜索" id="sbb"></input> </td></tr> <tr> <td> </td> <td nowrap="nowrap"> <table> <tr> <td> <input type="radio" name="sitesearch" value="" id="ss0"></input> <label for="ss0" title="搜索网络"><font size="-1" color="#000000">Web</font></label></td> <td> <input type="radio" name="sitesearch" value="wx35.cn" checked id="ss1"></input> <label for="ss1" title="搜索 wx35.cn"><font size="-1" color="#000000">wx35.cn</font></label></td> </tr> </table> <input type="hidden" name="client" value="pub-6811388601514482"></input> <input type="hidden" name="forid" value="1"></input> <input type="hidden" name="ie" value="UTF-8"></input> <input type="hidden" name="oe" value="UTF-8"></input> <input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#F7EFE7;VLC:663399;AH:center;BGC:F7EFE7;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:11"></input> <input type="hidden" name="hl" value="zh_CN"></input> </td></tr></table> </form> <!-- SiteSearch Google --> |
1 2 3 4 5 6 7 8 9 10 11 12 13 | <!-- Google Search Result Snippet Begins --> <div id="googleSearchUnitIframe"></div> <script type="text/javascript"> var googleSearchIframeName = 'googleSearchUnitIframe'; var googleSearchFrameWidth = 750; var googleSearchFrameborder = 0 ; var googleSearchDomain = 'www.google.cn'; </script> <script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"> </script> <!-- Google Search Result Snippet Ends --> |
最后在TEMPLATE目录下找到这些文件catalog.html,default.html,single.html,tags.html ,将其中的
1 2 3 4 | <form method="post" action="<#ZC_BLOG_HOST#>cmd.asp?act=Search"> <input type="text" name="edtSearch" id="edtSearch" size="12" /> <input type="submit" value="<#ZC_MSG087#>" name="btnPost" id="btnPost" /> </form> |
修改为
1 2 3 4 5 6 7 8 9 10 11 12 | <form method="get" action="https://www.wx35.cn/search.asp" target="_top"> <input type="hidden" name="domains" value="wx35.cn"> <input type="text" name="q" id="sbi" maxlength="255" value="" size="12" /> <input type="submit" value="搜索" name="sa" id="sbb" /> <input type="hidden" name="sitesearch" value="wx35.cn" checked id="ss1"> <input type="hidden" name="client" value="pub-6811388601514482"> <input type="hidden" name="forid" value="1"> <input type="hidden" name="ie" value="UTF-8"> <input type="hidden" name="oe" value="UTF-8"> <input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#F7EFE7;VLC:663399;AH:center;BGC:F7EFE7;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:11"> <input type="hidden" name="hl" value="zh_CN"> </form> |
https://www.wx35.cn/search.asp 是搜索页,修改为你自己的
wx35.cn 是搜索域名,修改为你自己的
pub-6811388601514482 是你的google分配号,修改为你自己的
到这里站内搜索就完成了,鉴于有些朋友修改过源码,实际代码可能与本文不符合,请自行检查代码区域。
Comments
3 Responses to “[原创]打造个性的站点 zblog站内搜索插件”
不错 可以用一下
马上就要过年了。支持一下啊
不错啊!!!!!!!!!!!!!!!!!