最近找点东西,深深体会到了bo-blog自带搜索的不足。无奈于bob沉迷于工口游戏及ero game不可自拔,bo-blog 3.0遥遥无期,在这青黄不接的时候我们能做什么呢?自然是发扬祖先的光荣传统,自己动手丰衣足食,拿起Google Custom Search强奸我们的blog。
===西红柿准备===
1.Google Custom Search申请入口,全中文界面,申请有困难的同学自备新华字典一本。
2.自定义搜索引擎创建成功后依次进入我的搜索引擎->控制面板->代码,点击在 Google 托管的网页上即可得到如下代码
<form action="http://www.google.com/cse" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="~!@##@%#^%DGSDGHT$%^%^&ZS" />
<input type="text" name="q" size="25" />
<input type="submit" name="sa" value="搜索" />
</div>
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=zh-Hans"></script>
<div>
<input type="hidden" name="cx" value="~!@##@%#^%DGSDGHT$%^%^&ZS" />
<input type="text" name="q" size="25" />
<input type="submit" name="sa" value="搜索" />
</div>
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=zh-Hans"></script>
其中~!@##@%#^%DGSDGHT$%^%^&ZS为用户识别码,这是我们后面所唯一需要的。
3.从这里开始将要对模板下手,模板的OOXX分为两类:
通用版:适用于搜索模块待在侧边的传统模板
打开模板的elements.php文件,于某个eot;后插入如下内容:
$elements['sideblock_search']=<<<eot
<div class="panel">
<h5 onclick='showhidediv("sidebar_search");'>搜索</h5>
<div class="panel-content" id="sidebar_search" style="display: block">
<form action="http://www.google.com/cse" id="cse-search-box">
<input type="hidden" name="cx" value="用户识别码" />
<input type="text" name="q" class="search-field" style="width:120px;"/>
<input type="submit" name="sa" value="搜索" class="button"/>
</form>
</div>
</div>
eot;
<div class="panel">
<h5 onclick='showhidediv("sidebar_search");'>搜索</h5>
<div class="panel-content" id="sidebar_search" style="display: block">
<form action="http://www.google.com/cse" id="cse-search-box">
<input type="hidden" name="cx" value="用户识别码" />
<input type="text" name="q" class="search-field" style="width:120px;"/>
<input type="submit" name="sa" value="搜索" class="button"/>
</form>
</div>
</div>
eot;
其中,用户识别码处请自行替换;文本框宽度120px可根据需要自由修改。
其他类:适用于搜索框跑至header的少数捣蛋分子
For G7 v5
打开模板的elements.php文件,查找
<form method="post" action="visit.php">
进行定位,将 <form method="post" action="visit.php">
<div>
<input name="job" type="hidden" value="search"/>
<input name="searchmethod" type="hidden" value="2"/>
<input name="keyword" type="text" id="search-text" class="keyword" value="输入搜索" onfocus="this.value=''" onfocus="this.value='输入搜索';this.style.color='gray';"/>
</div>
</form>
<div>
<input name="job" type="hidden" value="search"/>
<input name="searchmethod" type="hidden" value="2"/>
<input name="keyword" type="text" id="search-text" class="keyword" value="输入搜索" onfocus="this.value=''" onfocus="this.value='输入搜索';this.style.color='gray';"/>
</div>
</form>
替换为
<form action="http://www.google.com/cse" id="cse-search-box">
<div>
<input type="hidden" name="cx" value="用户识别码" />
<input name="q" type="text" id="search-text" class="keyword" value="输入搜索" onfocus="this.value=''" onfocus="this.value='输入搜索';this.style.color='gray';"/>
</div>
</form>
<div>
<input type="hidden" name="cx" value="用户识别码" />
<input name="q" type="text" id="search-text" class="keyword" value="输入搜索" onfocus="this.value=''" onfocus="this.value='输入搜索';this.style.color='gray';"/>
</div>
</form>
用户识别码处请自行替换
For BloggingPro
打开模板的elements.php文件,查找
<form method="post" action="visit.php">
进行定位,将 <form method="post" action="visit.php">
<input name="job" type="hidden" value="search"/>
<input name="searchmethod" type="hidden" value="2"/>
<input name="keyword" type="text" id="search-text" class="keyword"/>
<div id="buttonsearch"><input name="submit" type="image" class="search" title="Search" src="{$template['images']}/transparent.gif" alt="Search" value="Go" /></div>
</form>
<input name="job" type="hidden" value="search"/>
<input name="searchmethod" type="hidden" value="2"/>
<input name="keyword" type="text" id="search-text" class="keyword"/>
<div id="buttonsearch"><input name="submit" type="image" class="search" title="Search" src="{$template['images']}/transparent.gif" alt="Search" value="Go" /></div>
</form>
替换为
<form action="http://www.google.com/cse" id="cse-search-box">
<input type="hidden" name="cx" value="用户识别码" />
<input name="q" type="text" id="search-text" class="keyword"/>
<div id="buttonsearch"><input name="sa" type="image" class="search" title="Search" src="{$template['images']}/transparent.gif" alt="Search" value="Go" /></div>
</form>
<input type="hidden" name="cx" value="用户识别码" />
<input name="q" type="text" id="search-text" class="keyword"/>
<div id="buttonsearch"><input name="sa" type="image" class="search" title="Search" src="{$template['images']}/transparent.gif" alt="Search" value="Go" /></div>
</form>
用户识别码处请自行替换
更多修改请举一反三,拿起皮鞭SM你的大脑
===投掷开始===
广告时间:bo-blog 2.1.1进入测试阶段,急召小白
ps:感谢bob牺牲形象友情演出,以上攻击领导之段句纯属造谣。
This entry comes from 本站原创 and has been read for 1826 times.It is tagged with google自定义搜索blog-diy.



看起来听复杂的,还是等以后清楚了再弄!
啥时候出来啊?