站內搜索使用幫助
搜索功能作為建站系統是必不可少的,在V1.2.5版本后 支持搜索品牌、內容及自定義字段功能。
搜索結果均采用模糊搜索。
注意:標題是必搜索項目,不論怎么設定,標題都會被搜索到。
搜索參數一定要是數據庫中[wangji_content]表的字段名(不分大小寫),如content對應的事C_Content
> 基本搜索代碼(僅搜索標題):
~~~
<form method='post' action='{wangji:sitepath}search/' >
<input type="text" name='keys' value="{wangji:keys}" />
<input type='submit' value="搜索"/>
</form>
~~~
搜索內容字段(搜索標題+內容):
~~~
<form method='post' action='{wangji:sitepath}search/' >
<input type="hidden" name='searchcol' value="C_Content" />
<input type="text" name='keys' value="{wangji:keys}" />
<input type='submit' value="搜索"/>
</form>
~~~
搜索自定義字段(搜索標題+內容+作者+新聞類型):
~~~
<form method='post' action='{wangji:sitepath}search/' >
<input type="hidden" name='searchcol' value="C_Content,zauthor" />
<input type="text" name='keys' value="{wangji:keys}" />
<input type="hidden" name='type' value="news" />
<input type='submit' value="搜索"/>
</form>
~~~
搜索指定模型
1.3.6以后 支持多模型
<input type="hidden" name='type' value="news,product" />
1.3.6之前 只支持一種定義模型
~~~
<input type="hidden" name='type' value="product" /> '只搜索產品
<input type="hidden" name='type' value="news" /> '只搜索新聞
<input type="hidden" name='type' value="{wangji:type}" /> ‘搜索當前類型
~~~
通過以上兩個例子,大家可以看出來,只是增加了一個表單searchcol,值就是你要作為搜索的字段,支持多字段。
> 供用戶自己選擇的。
~~~
<form method='post' action='{wangji:sitepath}search/' >
<input type="text" name='keys' value="{wangji:keys}" />
<label><input type="checkbox" name="searchcol" value="c_content" >搜索內容</label>
<label><input type="checkbox" name="searchcol" value="zauthor">搜索作者</label>
<label> <input type="checkbox" name="searchcol" value="c_brand" >搜索品牌</label>
<input type='submit' value="搜索"/>
</form>
~~~
搜索內容?搜索作者?搜索品牌
搜索結果頁,標簽寫法和list標簽相同。
~~~
{wangji:search size=10 order=order}
[search:*]
{/wangji:search}
{list:page len=3 style=3}
~~~
演示:
~~~
{wangji:search size=5 order=order}
<li> <span>{formatdate:[search:date],1}</span>
<a href="[search:link]" title="[search:title]">[search:title]</a>
</li>
{/wangji:search} {list:page len=3 style=3}
~~~