本文整理汇总了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]);
}