/** * 前端初始化之一:检测主题设置 * * 独立出来的原因是不想在init中直接抛出异常。。。 * * @param string $theme * @return bool * @throws InvalidConfigException */ public function setTheme($theme) { $themes = CMSUtils::getThemeList(); if ($theme != '[none]' && !in_array($theme, $themes)) { throw new InvalidConfigException("错误的配置项,不支持的主题类型:「{$theme」。}"); } if ($theme != '[none]') { $this->view->theme = Yii::createObject(['class' => '\\yii\\base\\Theme', 'pathMap' => ['@app/views' => "@app/themes/{$theme}/views"]]); } return true; }
/** * 系统SEO设置 */ public function actionSeo() { $seo = new SeoForm(); $seo->setAttributes(CMSUtils::getSiteConfig('seo')); $seo->setOldAttributes($seo->attributes); if ($seo->load(Yii::$app->request->post())) { if ($row = $seo->save('seo')) { Yii::$app->cache->set('config_seo', $seo->attributes); } } return $this->render('seo', array('model' => $seo)); }