Exemple #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Classify::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['ID' => $this->ID, 'ModuleID' => $this->ModuleID, 'RootID' => $this->RootID, 'Depth' => $this->Depth, 'Orders' => $this->Orders, 'ParentID' => $this->ParentID, 'Child' => $this->Child, 'ShowCount' => $this->ShowCount]);
     $query->andFilterWhere(['like', 'ClassName', $this->ClassName])->andFilterWhere(['like', 'ClassName_e', $this->ClassName_e])->andFilterWhere(['like', 'Readme', $this->Readme])->andFilterWhere(['like', 'ParentStr', $this->ParentStr])->andFilterWhere(['like', 'ChildStr', $this->ChildStr]);
     return $dataProvider;
 }
Exemple #2
0
 public function actionIndex()
 {
     $classifyModel = new Classify();
     $dafenlei = $classifyModel->find()->where(["ParentID" => '0'])->limit(8)->all();
     // p($dafenlei);
     $articleModel = new MirArticle();
     $jobs = $articleModel->articleToIndex(5);
     //技术分享
     $jishus = $articleModel->articleToIndex(3);
     $productModel = new MirProduct();
     //ivd 五个广告图
     $adModel = new MirAd();
     $ads = $adModel->find()->orderBy("ad_rank desc,id desc")->limit(5)->all();
     // p($ads);
     // p($fourPic);
     // P($ivdList);
     // p(count($ivdList));
     //产品照片显示
     $mainClass = $productModel->mainClass();
     foreach ($mainClass as $k => $v) {
         $mainClassId[] = $k;
     }
     for ($i = 0; $i < count($mainClassId) - 1; $i++) {
         $products[] = MirProduct::find()->where(['product_mainclass' => $mainClassId[$i]])->orderBy("product_rank desc,product_id desc")->limit(9)->all();
         $data = $productModel->find()->where(["product_mainclass" => $mainClassId[$i]]);
         $pages = new Pagination(['totalCount' => $data->count(), 'pageSize' => '10']);
         $dataShow = $data->offset($pages->offset)->limit($pages->limit)->orderBy("product_rank desc,product_id desc")->all();
         $pagesArray[] = $pages;
         $productArray[] = $dataShow;
     }
     // p(count($products[1]));
     // p($pagesArray);
     // p($productArray);
     $mainClass = array_values($mainClass);
     return $this->render('index', ['dafenlei' => $dafenlei, 'jobs' => $jobs, 'jishus' => $jishus, 'ivdList' => $ivdList, 'mainClass' => $mainClass, 'products' => $products, 'productArray' => $productArray, 'pagesArray' => $pagesArray, 'ads' => $ads]);
 }
 /**
  * Lists all MirProduct models.
  * @return mixed
  */
 public function actionIndex()
 {
     $model = new MirProduct();
     $searchModel = new MirProductSearch();
     $params = Yii::$app->request->queryParams;
     $sort = trim(Yii::$app->request->get('sort'));
     if (empty($sort)) {
         $_GET['sort'] = '-product_id';
     }
     if (isset($params['MirProductSearch']['product_maker']) && !empty($params['MirProductSearch']['product_maker'])) {
         $params['MirProductSearch']['product_maker'] = $model->searchMaker($params['MirProductSearch']['product_maker']);
     }
     $dataProvider = $searchModel->search($params);
     $mainClass = Classify::mainClass();
     return $this->render('index', ['mainClass' => $mainClass, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 /**
  * Finds the Classify model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Classify the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Classify::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #5
0
                    <div class="panel-body">

                    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

                    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'product_id', 'headerOptions' => ['width' => '80']], 'product_name', ['attribute' => 'product_maker', 'value' => function ($data) {
    return MirProduct::makerMap($data->product_maker);
}], ['attribute' => 'product_pic', 'format' => 'raw', 'value' => function ($data) {
    /** 图片链接待确定 */
    return Html::img(Yii::getAlias('@uploads') . "/pro/" . $data->product_pic, ['width' => '172', 'height' => '56']);
}], ['attribute' => 'product_date', 'value' => function ($data) {
    return date('Y/m/d', strtotime($data->product_date));
}], ['attribute' => 'product_rank', 'headerOptions' => ['width' => 50]], ['attribute' => 'product_mainclass', 'headerOptions' => ['width' => 90], 'filter' => $mainClass, 'value' => function ($data) {
    $classify = Classify::mainClass();
    if ($data->product_mainclass == 0) {
        return $classify[$data->ID];
    } else {
        return $classify[$data->product_mainclass];
    }
}], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'template' => '{view}  {update} {delete}', 'headerOptions' => ['width' => '100']]]]);
?>


                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
Exemple #6
0
 /**
  * 产品主分类 用于下拉列表
  * @author wonguohui
  * @Date   2016-01-10T19:19:30+0800
  */
 public static function mainClass()
 {
     return \backend\models\Classify::mainClass();
 }