discuz X3.1 搜索框修改教程
摘要: 由于沭阳web网站使用的是discuz X3.1制作的,所以最近一段时间应该更新的教程更多的是discuz X3.1方面的,希望不会令大家失望,今天要和大家分享是的discuz X3.1 搜索框修改教程,都是沭阳web制作过程的分享,希望能 ...
由于沭阳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行的代码修改为如下的代码

3、我们从template/shuyangweb/common/header.htm中找到代码<!--{subtemplate common/pubsearchform}-->修改为<!--{subtemplate common/pubsearchform_cls}-->刷新预览下就能看到效果。
注:如果你觉得搜索框的位置不好的话,可以将<!--{subtemplate common/pubsearchform_cls}-->任意的放到其他的为止,最好前后加个DIV块,这样方便控制搜索框。
大家可以看下沭阳web的搜索框的位置:
1、首先大家要了解discuz的搜索的源文件在哪里:./Template/default/common/pubsearchform.htm
找 到这个文件后,复制该文件到你所在的模板风格的common文件夹下,我的风格文件夹为template/shuyangweb,建议大家重新命名该文件 pubsearchform_cls.htm,那么放入后为:template/shuyangweb/pubsearchform_cls.htm
2、直接将12~70行的代码修改为如下的代码
- <div id="search" class="{if $_G['setting']['srchhotkeywords'] && count($_G['setting']['srchhotkeywords']) > 5}scbar_narrow {/if}cl">
- <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">
- <input type="hidden" name="mod" id="scbar_mod" value="search" />
- <input type="hidden" name="formhash" value="{FORMHASH}" />
- <input type="hidden" name="srchtype" value="title" />
- <input type="hidden" name="srhfid" value="$_G[fid]" />
- <input type="hidden" name="srhlocality" value="$_G['basescript']::{CURMODULE}" />
- <!--{if !empty($searchparams[params])}-->
- <!--{loop $searchparams[params] $key $value}-->
- <!--{eval $srchotquery .= '&' . $key . '=' . rawurlencode($value);}-->
- <input type="hidden" name="$key" value="$value" />
- <!--{/loop}-->
- <input type="hidden" name="source" value="discuz" />
- <input type="hidden" name="fId" id="srchFId" value="$_G[fid]" />
- <input type="hidden" name="q" id="cloudsearchquery" value="" />
- <div style="display: none; position: absolute; top:37px; left:44px;" id="sg">
- <div id="st_box" cellpadding="2" cellspacing="0"></div>
- </div>
- <!--{/if}-->
- <table cellspacing="0" cellpadding="0">
- <tr>
- <td class="search_icon_td"></td>
- <td class="search_txt_td"><input type="text" name="srchtxt" id="search_txt" value="{lang enter_content}" autocomplete="off" x-webkit-speech speech /></td>
- <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>
- </tr>
- </table>
- </form>
- </div>

3、我们从template/shuyangweb/common/header.htm中找到代码<!--{subtemplate common/pubsearchform}-->修改为<!--{subtemplate common/pubsearchform_cls}-->刷新预览下就能看到效果。
注:如果你觉得搜索框的位置不好的话,可以将<!--{subtemplate common/pubsearchform_cls}-->任意的放到其他的为止,最好前后加个DIV块,这样方便控制搜索框。
大家可以看下沭阳web的搜索框的位置: