帝国cms搜索框表单代码
帝国cms 7.5 搜索框
一、根据数据表搜索:
<form action="/e/search/index.php" method="post" name="searchform" id="searchform">
<input type="hidden" name="show" value="title,newstext">
<input type="hidden" name="tempid" value="1">
<input name="keyboard" type="text" id="keyboard">
<select name="tbname">
<option value="news">问题库</option>
<option value="downl">视频教程</option>
</select>
<input type="submit" name="submit" value="搜索">
</form>
Show:搜索字段变量(多个字段用","隔开。搜索字段必须是后台系统模型开启搜索项的字段)
Tempid:所用搜索模板ID(一般跟按表搜索结合使用)
Keyboard:搜索关键字变量
Tbname:按数据表搜索(需与搜索模板ID结合Tempid)
按表时,搜索自定义字段一定要注意搜索模板选择的所属系统模型是否对应。
二、根据栏目id搜索:
<form name="searchform" method="post" action="/e/search/index.php">
<input type="hidden" name="show" value="title,newstext">
<input name="keyboard" type="text" size="10">
<select name="classid">
<option value="1">原创教程</option>
<option value="2">教程笔记</option>
<option value="3">软件插件</option>
<option value="4">问题记录</option>
<option value="5">摄影作品</option>
</select>
<input type="submit" name="submit" value="搜索">
</form>
//Show:搜索字段变量(多个字段用","隔开。搜索字段必须是后台系统模型开启搜索项的字段)
//Keyboard:搜索关键字变量
//Classid:搜索栏目ID(不设置为不限,多个栏目可用","隔开,设置父栏目会搜索所有子栏目)
三、搜索代码
<form action="[!--news.url--]e/search/index.php" method="post" name="searchform" id="searchform">
<input name="keyboard" id="keyboard" class="input_text" value="请输入关键字词" style="color: rgb(153, 153, 153);" onfocus="if(value=='请输入关键字词'){this.style.color='#000';value=''}" onblur="if(value==''){this.style.color='#999';value='请输入关键字词'}" type="text">
<input name="show" value="title" type="hidden">
<input name="tempid" value="1" type="hidden">
<input name="tbname" value="news" type="hidden">
<input name="Submit" class="input_submit" value="搜索" type="submit">
</form>
四、有多个模型的搜索代码
<div class="search">
<form action="[!--news.url--]e/search/index.php" method="post" name="searchform" id="searchform">
<input name="keyboard" id="keyboard" class="input_text" value="请输入关键字词" style="color: rgb(153, 153, 153);" onfocus="if(value=='请输入关键字词'){this.style.color='#000';value=''}" onblur="if(value==''){this.style.color='#999';value='请输入关键字词'}" type="text">
<input name="show" value="title" type="hidden">
<input name="tempid" value="1" type="hidden">
<select name="tbname">
<option value="article">杂志</option>
<option value="news">文章</option>
</select>
<input name="Submit" class="input_submit" value="搜索" type="submit">
</form>
</div>
五、全站搜索搜索代码
全站搜索表单语法说明:
1、全站搜索表单语法说明:
搜索表单提交地址:/e/sch/index.php
表单提交方式用:GET
keyboard:搜索关键字变量(前台搜索多个关键字可以用空格隔开)。
field:搜索字段变量,0为按后台设置搜索;1为按全文搜索;2为按标题搜索;3为按内容搜索。
classid:指定要搜索的栏目ID,多个栏目ID用逗号隔开。
2、表单范例:
<div class="search">
<form action="[!--news.url--]e/sch/index.php" method="get" name="searchform" id="searchform">
<input name="keyboard" id="keyboard" class="input_text" value="请输入关键字词" style="color: rgb(153, 153, 153);" onfocus="if(value=='请输入关键字词'){this.style.color='#000';value=''}" onblur="if(value==''){this.style.color='#999';value='请输入关键字词'}" type="text">
<input name="show" value="title,picsay,newstext,smalltext" type="hidden">
<input name="tempid" value="0" type="hidden">
<input name="tbname" value="news,photo" type="hidden">
<input name="Submit" class="input_submit" value="搜索" type="submit">
</form>
</div>
六、全站搜索搜索代码对应的模板是"公共模板"-“全站搜索模板”
<div class="weizhi">您当前的位置:系统搜索到约有<strong>[!--num--]</strong>项符合<strong>[!--keyboard--]</strong>的查询结果</div>
<div class="news_search">
<h2>搜索结果</h2>
<ul class="search_news">
[!--empirenews.listtemp--]
<li>[!--no.num--]. <a href="[!--titleurl--]" target="_blank">
<h2>[!--title--]</h2>
</a>
<p class="search_text">[!--smalltext--]</p>
<p class="search_info"><span>[!--titleurl--] - [!--newstime--]</span></p>
</li>
[!--empirenews.listtemp--]
</ul>
<div class="epages">[!--listpage--]</div>
</div>
案例展示,根据自己的需求设置css样式;
<form class="searchform " method="GET" action="[!--news.url--]e/sch/index.php"style="width:220px;max-width:100%;" name="search_news" onsubmit="return searchResult(this);" target="_blank">
<input type="text" style="border:1px solid #000000;color:#000000;font-size:12px;line-height:14px;padding-top:px;padding-bottom:px;height:37px;" name="keyboard" id="form_search" value="" placeholder="搜索学习需要学习的关键词">
<input type="hidden" name="tbname" value="news">
<input type="hidden" name="show" value="title">
<input type="hidden" name="tempid" value="1">
<input type="submit" class="assistive-text searchsubmit" value="Go!">
<a href="#go" style="width:auto;line-height: 37px;height: 37px;background: #000000 none repeat scroll 0 0;border: 0 none;border-radius: 0;color: #8d9095;cursor: pointer;font-size: 12px;font-weight: normal;margin: 0;padding: 0px 10px ;text-indent: 0;text-shadow: none;transition: all 0.2s ease 0s;right: 0;top:0px;" class="submit fa fa-search"></a>
</form>