步驟一:在默認搜索功能中添加代碼
在默認的搜索功能中添加以下代碼:
<input type="hidden" name="field" value="title|content|ext_wangzhi">
上述代碼中,type="hidden"
表示這是一個隱藏的輸入字段,name="field"
定義了字段的名稱,value="title|content|ext_wangzhi"
表示可以按照標題(title
)、內容(content
)或者新添加的字段(ext_wangzhi
)來搜索內容。
以下是整合到搜索表單中的完整代碼示例:
<form name="formsearch" action="{pboot:action}" method="get" class="form"> <input type="hidden" name="field" value="title|content|ext_wangzhi"> <input class="form-control input-lg" name="keyword" type="text" placeholder="輸入平臺全稱、平臺簡稱、公司名稱、公司網址等"> <button class="fa fa-search"></button> </form>
在上述代碼中,action="{pboot:action}"
定義了表單提交的目標地址,method="get"
定義了表單提交的方法,class="form"
定義了表單的樣式類。
步驟二:在搜索模板(search.html)中添加代碼
在搜索模板(search.html
)中添加以下代碼:
scode="" value="title|content|ext_wangzhi"
以下是整合到搜索模板中的完整代碼示例:
{pboot:search num=12 order=date scode="" value="title|content|ext_wangzhi"} <div class="col-xs-6 col-sm-4 col-md-3"> <div class="ten"> <a class="link" target="_blank" href="http://[list:ext_wangzhi]" rel="nofollow"></a> <h3><a class="href="[search:link]" title="[search:title]" target="_blank"><img src="[search:ico]">[search:title]</a></h3> <p>[search:description]...</p> </div> </div> {/pboot:search}
在上述代碼中,{pboot:search num=12 order=date scode="" value="title|content|ext_wangzhi"}
用于定義搜索的參數,num=12
表示每頁顯示的搜索結果數量,order=date
表示按照日期排序,scode=""
表示不限制欄目,value="title|content|ext_wangzhi"
表示按照自定義字段進行搜索。