POST TIME:2018-09-02 12:55
在制作dedecms模板通常會(huì)遇到這樣的要求 在織夢(mèng)之路上找到了解決方法 有需要的朋友可以拿去參考一下
思路:給搜索框加一個(gè)判定,例如搜索軟件模型的時(shí)候顯示一個(gè)模板,搜索文章模型的時(shí)候顯示一個(gè)模板。
1 在head區(qū)域加入
<script language="javascript" type="text/javascript">
<!–
function check(){
if(document.formsearch.channeltype.value=="3")
document.formsearch.action="{dede:field name=’phpurl’/}/search_images.php"
else
document.formsearch.action="{dede:field name=’phpurl’/}/search.php"
}
–>
</script>
2 更改搜索代碼
<form name="formsearch" action="" *****ubmit="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>
其中重點(diǎn)就是
<select name="channeltype" id="channeltype" >
<option value=’1′ selected=’1′>新聞</option>
<option value=’3′>軟件</option>
</select>
這里設(shè)置的按游戲模型搜索 1是文章模型3是軟件模型
3 復(fù)制serach.php 更名為search_images.php
4 打開(kāi)search_images.php
require_once(DEDEINC."/arc.searchview.class.php");
更改為
require_once(DEDEINC."/arc.searchimg.class.php");
5復(fù)制arc.searchview.class.php 更名為arc.searchimg.class.php
6 打開(kāi)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";
核心的修改已經(jīng)結(jié)束了,剩下的就是在search_images.htm這個(gè)模板里自由發(fā)揮了。
同理也可以實(shí)現(xiàn)按欄目type搜索顯示不同風(fēng)格的結(jié)果頁(yè)得。