2017 © Pedro Peláez
 

yii2-extension yii2-cms

Yii 2 CMS from Anda Tech

image

andatech/yii2-cms

Yii 2 CMS from Anda Tech

  • Tuesday, November 21, 2017
  • by madone
  • Repository
  • 3 Watchers
  • 1 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii2-cms

Yii 2 CMS from Anda Tech, (*1)

Main config

    ...
    'bootstrap' => [
        'log',
        'web-admin',
    ],
    ...
    'modules' => [
      'web-admin' => [
        'class' => 'anda\cms\Module',
        'tablePrefix' => 'web_',
        'uploadDir' => '@uploads/anda-cms',
        'uploadUrl' => '/uploads/anda-cms'
      ]
    ],
    'components' => [
      ...
      'andacms' => [
        'class' => 'anda\cms\components\API',
      ],
      ...
    ]

Sample Controller

    public function actionIndex()
    {
        $model = Yii::$app->andacms->getChildModule('news');
        $searchModel = $model->getSearchModel();
        $dataProvider = $model->getDataProvider();

        return $this->render('index',[
            'dataProvider' => $dataProvider,
            'searchModel' => $searchModel,
        ]);
    }

    public function actionView($id)
    {
        $model = Yii::$app->andacms->getChildModule('news')->view($id);
        if (Yii::$app->request->isAjax){
            return $this->renderAjax('view',[
                'model' => $model
            ]);
        }
        return $this->render('view',[
            'model' => $model
        ]);
    }

    public function actionFrontpage()
    {
        $render = Data::cache('frontpage'.ucfirst($this->id), 3600, function(){
            $model = Yii::$app->andacms->getChildModule($this->id);
            $model->getSearchModel();
            $dataProvider = $model->getDataProvider();
            $dataProvider->pagination->pageSize=$this->frontpageLimitItems;

            return $this->renderPartial('frontpage',[
                'dataProvider' => $dataProvider
            ]);
        });

        return $render;
    }


    public function actionCategory($id)
    {
        $categoryModel = Yii::$app->andacms->getChildModule('category')->get($id);

        $searchModel = Yii::$app->andacms->getChildModule($this->id)->getSearchModel();
        $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());
        $dataProvider->query->andFilterWhere(['category_id' => $id]);

        return $this->render('category',[
            'dataProvider' => $dataProvider,
            'searchModel' => $searchModel,
            'categoryModel' => $categoryModel
        ]);
    }

The Versions