默认版块

您所在的位置:合元网络»|||默认版块222222论坛 代码学习 默认版块 discuz如何在导航上加入搜索条!挺实用的  
打印 上一主题 下一主题

discuz如何在导航上加入搜索条!挺实用的

查看: 1335 发表于 2016-10-14 22:55:39 [复制链接]
  1. Step:1  打开template/default/common/common.css,找到以下代码,大概在595~607的位置
  2. #scbar { overflow: hidden; height: 42px; line-height: 42px; border-top: 1px solid #FFF; border-bottom: 1px solid #E9EFF5; background: #E8EFF5; }
  3.                                 .scbar_icon_td { width: 21px; background: url({IMGDIR}/search.png) no-repeat 0 -50px; }
  4.                                 .scbar_txt_td, .scbar_type_td { background: url({IMGDIR}/search.png) repeat-x 0 -93px; }
  5.                                         #scbar_txt { width: 400px; border: 1px solid #FFF; outline: none; }
  6.                                         .scbar_narrow #scbar_txt { width: 260px; }
  7.                                 .scbar_btn_td { width: 38px; background: url({IMGDIR}/search.png) no-repeat 8px -142px; }
  8.                                         #scbar_btn { margin: 0; padding: 0; border: none; background: transparent none; box-shadow: none; }
  9.                                                 #scbar_btn strong { line-height: 84px; }
  10.                                 .scbar_type_td { width: 61px; background: url({IMGDIR}/search.png) no-repeat 0 -193px; }
  11.                                         #scbar_type { display: block; padding-left: 10px; text-align: left; text-decoration: none; }
  12.                                                 #scbar_type_menu { margin-top: -8px; }
  13.                                 #scbar_hot { padding-left: 8px; height: 45px; overflow: hidden; }
  14.                                         #scbar_hot strong, #scbar_hot a { float: left; margin-right: 8px; white-space: nowrap;
  15. 复制代码
  16. 将其替换为以下代码:
  17. .scbar{ float:left; margin-top:11px; margin-left:10px; margin-right:10px; width:181px; overflow:hidden;}
  18.                                 #scbar{height: 26px; line-height:26px; border: none; border-radius: 5px; background: #FFFFFF;}        
  19.                                 #scbar_txt{ float: left; width: 150px; height: 26px; line-height: 26px; border: none; background: transparent; color: #444; font-size: 12px; text-indent: 5px; -webkit-transition: 0.2s width;transition: 0.2s width;}
  20.                                 #scbar_btn{float: left; width: 18px; height: 18px; margin: 0; background: transparent url({STYLEIMGDIR}/Searchicon.png) no-repeat 0 0; border: none; text-indent: -9999px; cursor: pointer; *padding-right:5px; _padding-right:5px;}
  21. 复制代码
  22. Step:2  打开template/default/common/header.htm,找到<!--{subtemplate common/pubsearchform}-->,并删除。之后找到<!--{hook/global_nav_extra}-->,替换为
  23. <div class="scbar"><!--{subtemplate common/pubsearchform}--></div>
  24.                                         <!--{hook/global_nav_extra}-->
  25. 复制代码
  26. Step:3  打开template/default/common/pubsearchform.htm,将以下代码,大概在41~75的位置
  27. <table cellspacing="0" cellpadding="0">
  28.                         <tr>
  29.                                 <td class="scbar_icon_td"></td>
  30.                                 <td class="scbar_txt_td"><input type="text" name="srchtxt" id="scbar_txt" value="{lang enter_content}" autocomplete="off" x-webkit-speech speech /></td>
  31.                                 <td class="scbar_type_td"><a href="javascript:;" id="scbar_type" class="xg1" onclick="showMenu(this.id)" hidefocus="true">{lang search}</a></td>
  32.                                 <td class="scbar_btn_td"><button type="submit" name="searchsubmit" id="scbar_btn" sc="1" class="pn pnc" value="true"><strong class="xi2">{lang search}</strong></button></td>
  33.                                 <td class="scbar_hot_td">
  34.                                         <div id="scbar_hot">
  35.                                                 <!--{if $_G['setting']['srchhotkeywords']}-->
  36.                                                         <strong class="xw1">{lang hot_search}: </strong>
  37.                                                         <!--{loop $_G['setting']['srchhotkeywords'] $val}-->
  38.                                                                 <!--{if $val=trim($val)}-->
  39.                                                                         <!--{eval $valenc=rawurlencode($val);}-->
  40.                                                                         <!--{block srchhotkeywords[]}-->
  41.                                                                                 <!--{if !empty($searchparams[url])}-->
  42.                                                                                         <a href="$searchparams[url]?q=$valenc&source=hotsearch{$srchotquery}" target="_blank" class="xi2" sc="1">$val</a>
  43.                                                                                 <!--{else}-->
  44.                                                                                         <a href="search.php?mod=forum&srchtxt=$valenc&formhash={FORMHASH}&searchsubmit=true&source=hotsearch" target="_blank" class="xi2" sc="1">$val</a>
  45.                                                                                 <!--{/if}-->
  46.                                                                         <!--{/block}-->
  47.                                                                 <!--{/if}-->
  48.                                                         <!--{/loop}-->
  49.                                                         <!--{echo implode('', $srchhotkeywords);}-->
  50.                                                 <!--{/if}-->
  51.                                         </div>
  52.                                 </td>
  53.                         </tr>
  54.                 </table>
  55.         </form>
  56. </div>
  57. <ul id="scbar_type_menu" class="p_pop" style="display: none;"><!--{echo implode('', $slist);}--></ul>
  58. <script type="text/javascript">
  59.         initSearchmenu('scbar', '$searchparams[url]');
  60. </script>
  61. <!--{/if}-->
  62. 复制代码
  63. 替换为:
  64.                 <table cellspacing="0" cellpadding="0">
  65.                         <tr>
  66.                                 <td><input type="text" name="srchtxt" id="scbar_txt" value="{lang enter_content}" autocomplete="off" x-webkit-speech speech /></td>
  67.                                 <td><button type="submit" name="searchsubmit" id="scbar_btn" sc="1" class="pn pnc" value="true"></button></td>
  68.                         </tr>
  69.                 </table>
  70.         </form>
  71. </div>
  72. <ul id="scbar_type_menu" class="p_pop" style="display: none;"><!--{echo implode('', $slist);}--></ul>
  73. <script type="text/javascript">
  74.         initSearchmenu('scbar', '$searchparams[url]');
  75. </script>
  76. <!--{/if}-->
  77. 复制代码
  78. Step:4  将图片上传到static/image/common目录下,请不要更改大小写
复制代码


— 产品中心

PRODUCT CENTER

— 产品中心

PRODUCT CENTER

CopyRight 2012-2017 合元网络 版权所有
公司地址:郑州市高新区升龙又一城A区2号楼2单元17楼 热线电话:15303843903 豫ICP备14027215号
快速回复 返回列表