織夢默認(rèn)代碼有這樣一個(gè)代碼,方便快捷解決這樣的難題。只需要在模板搜索代碼中加入 “<input type='hidden' name='typeid' value="欄目ID號(hào)">” 即可。
以下分享下實(shí)站操作案例:
要求:網(wǎng)站首頁有一個(gè)搜索;要求在產(chǎn)品欄目下增加一個(gè)搜索框,指定欄目文檔搜索。首頁的搜索框是全站內(nèi)容搜索,產(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="請輸入關(guān)鍵詞" onblur="if (this.value ==''){this.value=this.defaultValue}" onclick="if(this.value=='請輸入關(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="請輸入產(chǎn)品關(guān)鍵詞" class="s_w" onblur="if (this.value ==''){this.value=this.defaultValue}" onclick="if(this.value=='請輸入產(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)
搜索效果圖:
(此圖片來源于網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系刪除! )