當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Category::dropListHtml方法代碼示例

本文整理匯總了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]);
 }
開發者ID:wordnews,項目名稱:wei_shop,代碼行數:39,代碼來源:GoodsController.php


注:本文中的common\models\Category::dropListHtml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。