对于综合性站点来说,因为栏目过多,而访客关注的内容可能不同,比如有的网站是门户网站,里面分不同的城市,而不同城市的访客,可能只想搜索自己城市的新闻内容,对于这个就需要对搜索功能进行定制。

首先我们看看怎么对DEDE的搜索功能进行指定栏目或者频道

在搜索结果页添加:

<input type="hidden" name="typeid" value="1,4″ />

value="1,4″就是你要指定的一个或多个栏目,多个栏目用,号隔开。

例如:


<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>

知道了这个原理,那接下来我们就可以制定对全站所有栏目进行调用,让访客可以自己选择要搜索哪个栏目

生成栏目列表供访客选择,完整代码如下

<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>

免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。