本文整理匯總了PHP中common\models\Category::dropListHtml方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::dropListHtml方法的具體用法?PHP Category::dropListHtml怎麽用?PHP Category::dropListHtml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類common\models\Category
的用法示例。
在下文中一共展示了Category::dropListHtml方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionIndex
/**
* Lists all Goods models.
* @return mixed
*/
public function actionIndex()
{
if (!$this->is_access('goods/index')) {
Yii::$app->session->setFlash('error', $this->errorInfo);
return $this->redirect($this->redirectUrl);
}
$query = Goods::find()->where(['is_delete' => 0]);
$request = Yii::$app->request;
/* 搜索 begin */
if (($cat_id = $request->get('cat_id')) > 0) {
$query = $query->andWhere(['cat_id' => $cat_id]);
}
if (($brand_id = $request->get('brand_id')) > 0) {
$query = $query->andWhere(['brand_id' => $brand_id]);
}
if (($intro_type = $request->get('intro_type')) && $intro_type != 'is_all') {
$query = $query->andWhere([$intro_type => 1]);
}
if (is_numeric($is_on_sale = $request->get('is_on_sale'))) {
$query = $query->andWhere(['is_on_sale' => $is_on_sale]);
}
if (!empty($goods_name = $request->get('goods_name'))) {
$query = $query->andWhere("goods_name like '%{$goods_name}%'");
}
/* 搜索 end */
$dataProvider = new ActiveDataProvider(['query' => $query, 'Sort' => ['defaultOrder' => ['goods_id' => SORT_DESC]]]);
Yii::$app->view->params['meta_title'] = '商品列表';
// 商品分類
$Category = new Category();
$categoryList = $Category->dropListHtml();
// 品牌
$Brand = new Brand();
$brandList = $Brand->dropListHtml();
return $this->render('index', ['dataProvider' => $dataProvider, 'categoryList' => $categoryList, 'brandList' => $brandList]);
}