Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[修改] discuz X3.1 搜索框修改教程

[复制链接]
justzjg 发表于 2014-4-16 10:32:22 | 显示全部楼层 |阅读模式
由于沭阳web网站使用的是discuz X3.1制作的,所以最近一段时间应该更新的教程更多的是discuz X3.1方面的,希望不会令大家失望,今天要和大家分享是的discuz X3.1 搜索框修改教程,都是沭阳web制作过程的分享,希望能够帮助到discuz的应用者们。

1、首先大家要了解discuz的搜索的源文件在哪里:./Template/default/common/pubsearchform.htm

找到这个文件后,复制该文件到你所在的模板风格的common文件夹下,我的风格文件夹为template/shuyangweb,建议大家重新命名该文件pubsearchform_cls.htm,那么放入后为:template/shuyangweb/pubsearchform_cls.htm

2、直接将12~70行的代码修改为如下的代码

  1. <div id="search" class="{if $_G['setting']['srchhotkeywords'] && count($_G['setting']['srchhotkeywords']) > 5}scbar_narrow {/if}cl">
  2.     <form id="scbar_form" method="{if $_G[fid] && !empty($searchparams[url])}get{else}post{/if}" autocomplete="off" onsubmit="searchFocus($('scbar_txt'))" action="{if $_G[fid] && !empty($searchparams[url])}$searchparams[url]{else}search.php?searchsubmit=yes{/if}" target="_blank">
  3.         <input type="hidden" name="mod" id="scbar_mod" value="search" />
  4.         <input type="hidden" name="formhash" value="{FORMHASH}" />
  5.         <input type="hidden" name="srchtype" value="title" />
  6.         <input type="hidden" name="srhfid" value="$_G[fid]" />
  7.         <input type="hidden" name="srhlocality" value="$_G['basescript']::{CURMODULE}" />
  8.         <!--{if !empty($searchparams[params])}-->
  9.             <!--{loop $searchparams[params] $key $value}-->
  10.             <!--{eval $srchotquery .= '&' . $key . '=' . rawurlencode($value);}-->
  11.             <input type="hidden" name="$key" value="$value" />
  12.             <!--{/loop}-->
  13.             <input type="hidden" name="source" value="discuz" />
  14.             <input type="hidden" name="fId" id="srchFId" value="$_G[fid]" />
  15.             <input type="hidden" name="q" id="cloudsearchquery" value="" />
  16.             <div style="display: none; position: absolute; top:37px; left:44px;" id="sg">
  17.                 <div id="st_box" cellpadding="2" cellspacing="0"></div>
  18.             </div>
  19.         <!--{/if}-->
  20.         <table cellspacing="0" cellpadding="0">
  21.             <tr>
  22.                 <td class="search_icon_td"></td>
  23.                 <td class="search_txt_td"><input type="text" name="srchtxt" id="search_txt" value="{lang enter_content}" autocomplete="off" x-webkit-speech speech /></td>
  24.                 <td class="search_btn_td"><button type="submit" name="searchsubmit" id="search_btn" sc="1" class="search_pn" value="true"><strong class="xi2">{lang search}</strong></button></td>
  25.             </tr>
  26.         </table>
  27.     </form>
  28. </div>
复制代码
直接刷新首页后,会看到搜索框直接变成了如下图的效果:

3、我们从template/shuyangweb/common/header.htm中找到代码<!--{subtemplate common/pubsearchform}-->修改为<!--{subtemplate common/pubsearchform_cls}-->刷新预览下就能看到效果。

注:如果你觉得搜索框的位置不好的话,可以将<!--{subtemplate common/pubsearchform_cls}-->任意的放到其他的为止,最好前后加个DIV块,这样方便控制搜索框。

大家可以看下沭阳web的搜索框的位置:

预览地址:http://www.shuyangweb.com/article-12-1.html

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
z110110 发表于 2014-6-27 23:09:53 | 显示全部楼层
顶一下。。教程收藏
回复

使用道具 举报

navyyang 发表于 2014-7-17 14:13:08 | 显示全部楼层
谢谢。学习一下
回复

使用道具 举报

navyyang 发表于 2014-9-10 14:43:16 | 显示全部楼层
这个改了之后会有问题。默认搜索不对了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-18 19:25 , Processed in 0.121191 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表