dedecms程序本身自帶的模板有圖片模型、文章模型、軟件模型等,有時候為了用戶體驗需要給搜索框加一個判定,例如搜索軟件模型的時候顯示軟件模型的模板,搜索文章模型的時候顯示文章模型的模板。
具體的修改方法如下:
- 在head區域加入
<script language="javascript" type="text/javascript">function check(){if(document.formsearch.channeltype.value=="1")document.formsearch.action="{dede:field name='phpurl'/}/search.php"elsedocument.formsearch.action="{dede:field name='phpurl'/}/search_img.php"}</script>
- 更改搜索代碼
<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>
詳解
value='1'和value='3'模型搜索1是文章模型,3是軟件模型
復制serach.php更名為 search_img.php
打開search_img.php文件
找到
require_once(DEDEINC."/arc.searchview.class.php");
改為
require_once(DEDEINC."/arc.searchimg.class.php");
復制arc.searchview.class.php更名為arc.searchimg.class.php
打開 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_img.htm";


