如何為搜索增加限定條件?
模板文件:/web/templates/pc/default/home/book/search.html
比如,我們給圖書(shū)自定義了一個(gè)主表“字?jǐn)?shù)”字段 $zishu,需求:只搜索出圖書(shū)字?jǐn)?shù)>3000字的書(shū)
{php $where = urlencode("zishu>3000");}
{search order=$params.order id=$searchid where=$where total=$sototal catid=$catid page=1 pagesize=30 urlrule=$urlrule}
這里顯示
{/search}
這樣寫(xiě)又不行了。。。
搜索標(biāo)簽只能通過(guò)重寫(xiě)控制器類的方法來(lái)實(shí)現(xiàn)了
dayrui\App\News\Models\ 下新建 Search.php
<?php namespace Phpcmf\Model\News;
// 模塊內(nèi)容搜索類
class Search extends \Phpcmf\Model\Search {
// 獲取搜索參數(shù)
public function get_param($module) {
list($catid, $get) = parent::get_param($module);
// 這里可以重組$get變量
return [$catid, $get];
}
// 自定義組合查詢條件
protected function mysearch($module, $where, $get) {
// 重新對(duì)where條件的組裝
// 比如我加一個(gè)條件作為搜索條件
$where[] = "zt=1"; // 表加一個(gè)zt字段=1的數(shù)據(jù)
return $where;
}
}
News 換成你的模塊名稱 條件字段也換成你的
你這是xunruicms的方法啊,pos根本不能用這個(gè)方法
回復(fù)@小趙
沒(méi)有得到可解決問(wèn)題的回答,結(jié)貼。