您现在的位置是:网站首页 > 脚本编程>

dedecms搜索结果页按频道模型显示不同模板

2013-09-294044人围观
简介 dedecms门户模板的时候经常会有图片模型、文章模型、软件模型之类的,要是给搜索框加一个判定,例如搜索软件模型的时候显示一个模板,搜索文章模型的时候显示一个模板。 具体实现代码: 1 在head区域加入

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


打赏本站,你说多少就多少

本文地址:https://www.qi522.com/view/30.html

来     源:千奇博客

精彩评论

微信关注

Copyright © 2013-2019 千奇博客 保留所有权利 辽ICP备13008238号