可樂在幫客戶建設(shè)網(wǎng)站時(shí),經(jīng)常碰到用戶要求指定欄目文檔搜索,比如產(chǎn)品總欄目加一個(gè)搜索框,只搜索產(chǎn)品欄目下的產(chǎn)品。于是從網(wǎng)上百度了下教程,有一個(gè)方法是修改arc.searchview.class.php文件來完成的,但是這樣會(huì)造成所有的搜索結(jié)果都會(huì)指定。
織夢(mèng)默認(rèn)代碼有這樣一個(gè)代碼,方便快捷解決這樣的難題。只需要在模板搜索代碼中加入 “”<input type='hidden' name='typeid' value="欄目ID號(hào)">“” 即可。
以下分享下實(shí)站操作案例:
首頁搜索框代碼為:
<form action="/plus/search.php" name="formsearch">
<input type="hidden" name="kwtype" value="0">
<input type='hidden' name='typeid' value="4">
<input type="text" name="q" value="請(qǐng)輸入關(guān)鍵詞" onblur="if (this.value ==''){this.value=this.defaultValue}" onclick="if(this.value=='請(qǐng)輸入關(guān)鍵詞')this.value=''">
<input type="submit" name="submit" value="搜 索" style="border:0">
</form>
|
產(chǎn)品欄目下搜索框代碼為:
<form action="/plus/search.php" name="formsearch">
<input type="hidden" name="kwtype" value="0">
<input type='hidden' name='typeid' value="4">
<input type="text" name="q" value="請(qǐng)輸入產(chǎn)品關(guān)鍵詞" class="s_w" onblur="if (this.value ==''){this.value=this.defaultValue}" onclick="if(this.value=='請(qǐng)輸入產(chǎn)品關(guān)鍵詞')this.value=''">
<input type="submit" name="submit" value="搜 索" style="border:0">
</form>
|
指定欄目搜素,只需要加入如下代碼即可:
<input type='hidden' name='typeid' value="4"> 這里的4為指定欄目的ID號(hào) |
推薦閱讀:dedecms中英文網(wǎng)站之中英文搜索方法