Home  >  Article  >  CMS Tutorial  >  How does DEDE integrate the search bar?

How does DEDE integrate the search bar?

藏色散人
藏色散人Original
2019-12-25 10:43:282620browse

How does DEDE integrate the search bar?

DEDE怎么集成搜索栏?

这篇文章主要介绍了DEDE集成百度搜索谷歌搜索站内全站搜索站内按栏目搜索等功能的搜索栏,可以让访客点选使用百度搜索站内内容或者用谷歌搜索站点内容,或者直接搜索整站内容,或者点选按栏目搜索站内内容,感兴趣的小伙伴们可以参考一下

  推荐学习:织梦cms

DEDE可定制性非常强,我们接到一个项目,要求定制站点的搜索框,要求能有个选项,可以让访客点选使用百度搜索站内内容或者用谷歌搜索站点内容,或者直接搜索整站内容,或者点选按栏目搜索站内内容

全部代码如下:

<div class="search-bg">
  <div class="inner">
    <div class="search-form">
   <form role="search" method="get" id="searchform" name=bf onSubmit="bottomForm();return false;">
<script> 
function bottomForm(){
var $=document.bf.key.value; 
var $2=document.bf.sto.value; 
if(document.bf.sto[0].selected)window.open("https://www.baidu.com/s?wd="+"site%3Abnxb.com+"+$); 
if(document.bf.sto[1].selected)window.open("https://www.google.com.hk/search?hl=zh-CN&source=hp&q="+"site%3Awww.bnxb.com+"+$);
if(document.bf.sto[2].selected)window.open("{dede:global.cfg_basehost/}/app/search.php?kwtype=1&keyword="+$); 
else window.open("{dede:global.cfg_basehost/}/app/search.php?kwtype=1&keyword="+$+"&typeid="+$2);
return false} 
</script>
<input name="key" id="s" class="s" value="请输入关键词开始搜索!"onClick="this.value = &#39;&#39;;" style="background-color: rgb(255, 255, 255); color: rgb(153, 153, 153); opacity: 0.8664601413572597; background-position: initial initial; background-repeat: initial initial; "onKeyPress="javascript:if(event.keyCode == 13){query(this.value);}" x-webkit-speech="" type="text">
<SELECT class="search-select" name="sto" id="search-option"> 
               <option value="0" class="search-select-option">百度搜索</option>
               <option value="1111" class="search-select-option">谷歌搜索</option>
   <option value="2222" selected=&#39;1&#39; class="search-select-option">全站搜索</option>
{dede:channelartlist typeid=&#39;top&#39; }
{dede:type} <option value=&#39;[field:id/]&#39;>[field:typename/]</option>{/dede:type}
{dede:channel type=&#39;son&#39; noself=&#39;yes&#39;}
<option value=&#39;[field:id/]&#39;>--[field:typename/]</option>
{/dede:channel}
{/dede:channelartlist}
</select>
<button id="searchsubmit" class="btn">搜索</button>
</form>
    </div>
    <div class="tagscloud"> <span>快捷搜索:</span>  {dede:hotwords num=&#39;5&#39;subday=&#39;30&#39; maxlength=&#39;10&#39;/}   </div>
  </div>
</div>

CSS如下

/*search-bg*/
.search-bg {background-color:#F5F5F5; width:100%; padding:20px 0; display:none;}
.search-bg.search-open {display:block;}
.search-bg .inner {overflow:hidden;}
.search-form,.search-form input {float:left;}
.search-form .s {background-color:#fff; border:1px solid #ddd; height:22px; line-height:22px; padding:5px; font-size:0.875em; width:500px; border-radius:3px;}
.search-form button {border:none; background-color:#1e82aa; color:#fff; height:32px; padding:0 10px; cursor:pointer; margin:1px 0px; border-radius:6px; font-size:1em;}
.search-form .search-select {background-color:#fff; border:1px solid #ddd; height:34px; line-height:34px; margin:1px 5px;}
.search-form .search-select-option {background-color:#E9EAEC;font-weight:bold}

The above is the detailed content of How does DEDE integrate the search bar?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn