织梦网站模板的检索作用非常好用,但有时大家会必须一些独特的检索状况,比如大家网址中必须依据频道栏目不一样,启用不一样的百度搜索页模版。文中就来教大伙儿如何启用不一样的检索页模版。DedeCMS自身内置的模版有照片实体模型、文章内容实体模型、手机软件实体模型等,有时为了更好地客户体验必须给输入框加一个判断,比如搜索神器实体模型的情况下表明手机软件实体模型的模版,搜索文章实体模型的情况下表明文章内容实体模型的模版。

实际的完成编码以下:

 

1.在head地区添加以下编码:

<span style="font-size:14px;"><script language="javascript" type="text/javascript">

function check(){

if(document.formsearch.channeltype.value=="1")

document.formsearch.action="{dede:field name='phpurl'/}/search.php"

else

document.formsearch.action="{dede:field name='phpurl'/}/search_news.php"}

</script></span>

这一段编码关键用于分辨你挑选了哪些频道栏目,依据你挑选的频道栏目的不一样,来应用不一样的检索页模版。

 

2.变更检索编码

<span style="font-size:14px;"><form name="formsearch" action="" data-ke-onsubmit="check();">

<div class="form">

<input type="hidden" name="kwtype" value="0" />

<input name="q" type="text" class="search-keyword" id="search-keyword" value="{dede:global name='keyword' function='RemoveXSS(@me)'/}" />

<select name="channeltype" id="channeltype" >

<option value='1' selected='1'>新闻报道</option>

<option value='3'>手机软件</option>

</select>

<button type="submit" class="search-submit">检索</button>

</div>

</form></span>

在其中关键便是

<span style="font-size:14px;"><select name="channeltype" id="channeltype" >

<option value='1' selected='1'>新闻报道</option>

<option value='3'>手机软件</option>

</select></span>

重要设定:这儿设定的按实体模型检索  1是文章内容实体模型 3是手机软件实体模型

 

3.拷贝/plus/serach.php 改名为 /plus/search_images.php

 

4.开启 search_images.php将以下编码:

require_once(DEDEINC."/arc.searchview.class.php");

更改成

require_once(DEDEINC."/arc.searchimg.class.php");

 

5.拷贝 /include/arc.searchview.class.php 改名为 /include/arc.searchimg.class.php

 

6.开启 arc.searchimg.class.php搜索以下编码:

$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search.htm";

 

更改成

$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/search_images.htm

 

做了上边的实际操作,基本上就可以启用出不一样的检索页模版了。



评论(0条)

刀客源码 游客评论