Pbootcms網(wǎng)站多條件搜索標(biāo)簽調(diào)用
多條件搜索
適用范圍:全站任意地方均可使用
標(biāo)簽作用:用于執(zhí)行站內(nèi)搜索功能
1、最簡單的搜索示例
<form action="{pboot:scaction}" ?method="get">
????關(guān)鍵字:<input type="text" name="keyword" >
????<button type="submit">搜索</button>
</form>
使用說明:
{pboot:scaction} 為搜索提交地址
注意:表單提交方式為get,此表單默認(rèn)匹配title標(biāo)題字段
2、定義搜索字段示例
<form action="{pboot:scaction}" ?method="get">
????關(guān)鍵字:<input type="text" name="keyword" >
????<input type="hidden" name="field" value="title" >
????<button type="submit">搜索</button>
</form>
或:
<form action="{pboot:scaction}" ?method="get">
?
????<select name="field">
????????<option value="title">內(nèi)容標(biāo)題</option>
????????<option value="content">內(nèi)容詳情</option>
????</select>
????關(guān)鍵字:<input type="text" name="keyword" >
????<button type="submit">搜索</button>
</form>
3、定義更多搜索條件示例
<form action="{pboot:scaction}" ?method="get">
????關(guān)鍵字:<input type="text" name="keyword" >
????<input type="hidden" name="field" value="title" >
????<input type="hidden" name="scode" value="2,3" >
????<button type="submit">搜索</button>
</form>
(V1.3.7+)如果有多個搜索表單想定義不同的結(jié)果頁模板,那么可以傳遞searchtpl字段來定義模板頁,如:
<input type=”hidden” name=”searchtpl” value=”test.html” >
4、多條件綜合搜索示例
<form action="{pboot:scaction}" ?method="get">
????內(nèi)容:<input type="text" name="content" >
????標(biāo)題:<input type="text" name="title" >
????作者:<input type="text" name="author" >
????<input type="hidden" name="scode" value="2,3" >
????<button type="submit">搜索</button>
</form>
? ? 這里自定義了三個字段,其實(shí)你可以定義更多數(shù)據(jù)庫中任意可用的字段。
如果URL采用兼容模式,這時候搜索應(yīng)該使用POST,或者在首行添加隱藏域,<input type=”hidden
” name=”search” >
5、搜索結(jié)果列表
{pboot:search}
<a href="[search:link]">[search:title]</a>
{/pboot:search}
使用說明:
搜索結(jié)果頁面使用模板search.html
num=* ?每頁數(shù)量,非必填,用于控制分頁大小
order=* ? 排序方式,非必填,用于輸出內(nèi)容的排序方式,可選:date、sorting、istop、isrecommend、isheadline、visits、likes、oppose等字段,其中sorting為按后臺填寫的排序,122版本開始支持自定義模式,如:order=’date desc,id desc’ 、order=’sorting desc,id desc’,(V1.3.7+)還支持random隨機(jī)排序
scode=* ?分類編碼,非必填,加前面說的方式,此作為第二種限制搜索分類的方式,多個分類用逗號隔開,如: scode=’2,3,4′
field=* 字段限制,非必填,在使用了keyword時用于限定匹配的數(shù)據(jù)庫字段,多個字段用豎線隔開即可,如:field=’title|content’
filter=*|x,y 數(shù)據(jù)過濾,非必填,用于對列表內(nèi)容進(jìn)行過濾篩選,如:filter=title|ASP,PHP 只顯示標(biāo)題含有ASP和PHP的內(nèi)容
fuzzy=* ?是否模糊匹配,非必填,可選1或0,1時為默認(rèn)的模糊匹配,0則關(guān)閉
6、搜索結(jié)果列表可用標(biāo)簽
獲取當(dāng)前搜索內(nèi)容:{pboot:keyword}
對搜索結(jié)果關(guān)鍵字進(jìn)行標(biāo)紅 mark=1 (V2.0.5新增),如:[search:title mark=1];
[search:n] | 序號從0開始 |
[search:i] | 序號從1開始 |
[search:id] | 編號 |
[search:scode] | 分類編碼 |
[search:subscode] | 副分類編碼 |
[search:sortname] | 分類名稱 |
[search:subsortname] | 副分類名稱 |
[search:sortlink] | 分類鏈接 |
[search:subsortlink] | 副分類鏈接 |
[search:title] | 標(biāo)題 |
[search:titlecolor] | 標(biāo)題顏色 |
[search:subtitle] | 副標(biāo)題 |
[search:author] | 作者 |
[search:source] | 來源 |
[search:link] | 鏈接 |
[search:outlink] | 外部鏈接 |
[search:date] | 發(fā)布日期 |
[search:ico] | 縮略圖 |
[search:pics] | 多圖 |
[search:content] | 內(nèi)容 |
[search:enclosure] | 附件 |
[search:enclosuresize] | 附件大小 |
[search:keywords] | 關(guān)鍵詞 |
[search:description] | 描述 |
[search:istop] | 是否置頂 |
[search:isrecommend] | 是否推薦 |
[search:isheadline] | 是否頭條 |
[search:visits] | 訪問數(shù)量 |
[search:likes] | 點(diǎn)贊數(shù)量 |
[search:oppose] | 反對數(shù)量 |
[search:likeslink] | 點(diǎn)贊鏈接 |
[search:opposelink] | 反對鏈接 |