站内搜索使用帮助 搜索功能作为建站系统是必不可少的,在V1.2.5版本后 支持搜索品牌、内容及自定义字段功能。
搜索结果均采用模糊搜索。
注意:标题是必搜索项目,不论怎么设定,标题都会被搜索到。 搜索参数一定要是数据库中[zzz_content]表的字段名(不分大小写),如content对应的事C_Content 基本搜索代码(仅搜索标题): - <form method='post' action='{zzz:sitepath}search/' >
- <input type="text" name='keys' value="{zzz:keys}" />
- <input type='submit' value="搜索"/>
- </form>
复制代码
搜索内容字段(搜索标题+内容): - <form method='post' action='{zzz:sitepath}search/' >
- <input type="hidden" name='searchcol' value="C_Content" />
- <input type="text" name='keys' value="{zzz:keys}" />
- <input type='submit' value="搜索"/>
- </form>
复制代码
搜索自定义字段(搜索标题+内容+作者+新闻类型): - <form method='post' action='{zzz:sitepath}search/' >
- <input type="hidden" name='searchcol' value="C_Content,zauthor" />
- <input type="text" name='keys' value="{zzz: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="{zzz:type}" /> ‘搜索当前类型
复制代码
通过以上两个例子,大家可以看出来,只是增加了一个表单searchcol,值就是你要作为搜索的字段,支持多字段。 供用户自己选择的。 - <form method='post' action='{zzz:sitepath}search/' >
- <input type="text" name='keys' value="{zzz: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标签相同。- {zzz:search size=10 order=order}
- [search:*]
- {/zzz:search}
- {list:page len=3 style=3}
复制代码
演示:- {zzz:search size=5 order=order}
- <li> <span>{formatdate:[search:date],1}</span>
- <a href="[search:link]" title="[search:title]">[search:title]</a>
- </li>
- {/zzz:search}
- {list:page len=3 style=3}
复制代码
|