2017 © Pedro Peláez
 

yii2-extension yii2-cms

Yii 2 CMS from culture-pn-psu Tech

image

culture-pn-psu/yii2-cms

Yii 2 CMS from culture-pn-psu Tech

  • Friday, March 3, 2017
  • by madone
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 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' => 'culturePnPsu\cms\Module',
        'tablePrefix' => 'web_',
        'uploadDir' => '@uploads/web-cms/',
        'uploadUrl' => '/uploads/anda-cms'
      ]
    ],
    'components' => [
      ...
      'andacms' => [
        'class' => 'culturePnPsu\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