織夢dedecms設置不一樣的搜索頁模板教程

1.在head區域加入以下代碼:
<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>
    這段代碼主要用來判斷你選擇了什麼頻道,根據你選擇的頻道的不一樣,來使用不一樣的搜索頁模板。
 
2.更改搜索代碼
<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>
 
其中重點就是
 
<select name="channeltype" id="channeltype" >
<option value='1' selected='1'>新聞</option>
<option value='3'>軟件</option>
</select>
 
關鍵設置:這裏設置的按模型搜索  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
 
作完上面的操做,基本就能夠調用出不一樣的搜索頁模板了。
相關文章
相關標籤/搜索