Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

织梦搜索结果页实现按频道模型显示不同结果模板

织梦教程:dedecms教程搜索结果页实现按频道模型显示不同结果模板!dedecms本身自带的织梦模板有图片模型、文章模型、软件模型等。

织梦教程:dedecms教程搜索结果页实现按频道模型显示不同结果模板!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.复制serach.php 更名为 search_images.php

4.打开 search_images.php

代码如下:

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

更改为

代码如下:

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

5.复制 arc.searchview.class.php 更名为 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
温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
编程技巧

织梦教程DedeCMS系统tag标签使用方法

2023-3-16 0:00:00

编程技巧

WordPress最新文章列表中排除置顶文章

2023-3-20 0:00:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索