温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

织梦搜索结果页按频道模型显示不同模板的方法

发布时间:2020-08-18 14:49:43 来源:亿速云 阅读:124 作者:小新 栏目:建站服务器

这篇文章主要介绍了织梦搜索结果页按频道模型显示不同模板的方法,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获。下面让小编带着大家一起了解一下。

织梦搜索结果页怎么按频道模型显示不同模板?

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

推荐学习:织梦cms

思路: 给搜索框加一个判定,例如搜索软件模型的时候显示一个模板,搜索文章模型的时候显示一个模板。

1.在head区域加入

<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>

其中重点就是

<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";

核心的修改已经结束了,剩下的就是在search_images.htm这个模板里自由发挥了。同理也可以实现按栏目type搜索显示不同风格的结果页得。

感谢你能够认真阅读完这篇文章,希望小编分享织梦搜索结果页按频道模型显示不同模板的方法内容对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,遇到问题就找亿速云,详细的解决方法等着你来学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI