聯(lián)系官方銷售客服
1835022288
028-61286886
如何為搜索增加限定條件?
模板文件:/web/templates/pc/default/home/book/search.html
比如,我們給圖書自定義了一個主表“字?jǐn)?shù)”字段 $zishu,需求:只搜索出圖書字?jǐn)?shù)>3000字的書
{php $where = urlencode("zishu>3000");}
{search order=$params.order id=$searchid where=$where total=$sototal catid=$catid page=1 pagesize=30 urlrule=$urlrule}
這里顯示
{/search}
這樣寫又不行了。。。
搜索標(biāo)簽只能通過重寫控制器類的方法來實現(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) {
// 重新對where條件的組裝
// 比如我加一個條件作為搜索條件
$where[] = "zt=1"; // 表加一個zt字段=1的數(shù)據(jù)
return $where;
}
}
News 換成你的模塊名稱 條件字段也換成你的
你這是xunruicms的方法啊,pos根本不能用這個方法
回復(fù)@小趙
沒有得到可解決問題的回答,結(jié)貼。