對(duì)于綜合性站點(diǎn)來(lái)說(shuō),因?yàn)闄谀窟^(guò)多,而訪客關(guān)注的內(nèi)容可能不同,比如有的網(wǎng)站是門戶網(wǎng)站,里面分不同的城市,而不同城市的訪客,可能只想搜索自己城市的新聞內(nèi)容,對(duì)于這個(gè)就需要對(duì)搜索功能進(jìn)行定制。
首先我們看看怎么對(duì)DEDE的搜索功能進(jìn)行指定欄目或者頻道
在搜索結(jié)果頁(yè)添加:
<input type="hidden" name="typeid" value="1,4″ />
value="1,4″就是你要指定的一個(gè)或多個(gè)欄目,多個(gè)欄目用,號(hào)隔開(kāi)。
例如:
<form name="formsearch" action="{dede:global.cfg_cmsurl/}/plus/search.php"><div class="form"><h4>搜索</h4><input type="hidden" name="kwtype" value="0″ /><input type="hidden" name="typeid" value="1,4″ /><input name="q" type="text" class="search-keyword" id="search-keyword"value="在這里搜索…" onfocus="if(this.value=='在這里搜索…'){this.value=";}" onblur="if(this.value=="){this.value='在這里搜索…';}" /><button type="submit" class="search-submit">搜索</button></div></form> |
知道了這個(gè)原理,那接下來(lái)我們就可以制定對(duì)全站所有欄目進(jìn)行調(diào)用,讓訪客可以自己選擇要搜索哪個(gè)欄目
生成欄目列表供訪客選擇,完整代碼如下
<form action="{dede:field name='phpurl'/}/search.php" name="formsearch"><div class="form"><h4>搜索</h4><input type="hidden" name="kwtype" value="0" /><input type="hidden" name="searchtype" value="titlekeyword" /><input name="keyword" type="text" class="search-keyword" id="search-keyword"/><select name="typeid" class="search-option" id="typeid"><option value='0' selected='1'>全部欄目</option>{dede:channelartlist typeid='top' }{dede:type} <option value='[field:id/]'>[field:typename/]</option>{/dede:type}{dede:channel type='son' noself='yes'}<option value='[field:id/]'>-[field:typename/]</option>{/dede:channel}{/dede:channelartlist}</select><button type="submit" class="search-submit">搜索</button></div></form> |
新聞熱點(diǎn)
疑難解答
圖片精選