public function init() { parent::init(); if ($this->_superior = SiteModule::findOne(['site_id' => $this->siteId, 'type' => SiteModule::TYPE_MENU, 'position' => $this->position, 'status' => SiteModule::STATUS_ENABLED])) { $this->items = $this->_superior->getItems()->where(['site_id' => $this->siteId, 'status' => SiteModuleItem::STATUS_ENABLED])->orderby('list_order desc, created_at')->all(); } }
public function init() { parent::init(); if ($this->_superior = SiteModule::findOne(['site_id' => $this->siteId, 'type' => SiteModule::TYPE_BANNER, 'position' => $this->position, 'status' => SiteModule::STATUS_ENABLED])) { $this->items = $this->_superior->getItems()->where(['site_id' => $this->siteId, 'status' => SiteModuleItem::STATUS_ENABLED])->orderby('list_order desc, created_at')->all(); } if ($this->items && $this->carousel) { $this->options['id'] = $this->randomId; $this->view->registerJs("\$('#{$this->randomId}').carousel();", 3); } }
public function actionDelete() { $item = SiteModule::findOne(['id' => \Yii::$app->request->post('id', 0), 'site_id' => $this->module->siteId]); $done = $item && $item->delete(); return \Yii::$app->request->isAjax ? $this->respond(['error' => !$done, 'message' => \Yii::t($this->module->messageCategory, 'operation ' . ($done ? 'succeeded' : 'failed')) . ($done ? '' : ', ' . \Yii::t($this->module->messageCategory, 'please try again'))]) : $this->goBack(); }
public function actionList($stype = null, $sword = null) { $query = SiteModule::find()->where(['site_id' => $this->module->siteId, 'type' => SiteModule::TYPE_MENU])->orderby('created_at desc'); if ($sword !== null) { $query->andWhere(['like', "{$stype}", $sword]); } $pagination = new Pagination(['totalCount' => $query->count()]); $items = $query->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render($this->action->id, ['stype' => $stype, 'sword' => $sword, 'items' => $items, 'pagination' => $pagination]); }
/** * Get sub module belongs it * * @since 0.0.1 * @return {object} */ public function getSubModule() { return $this->hasOne(SiteModule::classname(), ['id' => 'sub_module_id']); }