はので、私はhttp://www.yiiframework.com/doc-2.0/guide-output-theming.html以下、この構造のフロントエンド/ウェブ/テーマ/ myTheme
を作成した私は、フロントエンド/設定/メインにこのコードを追加しました。 PHPYii2高度変更ビューのデフォルトパス(テーマ)
'components' => [
'view' => [
'theme' => [
'basePath' => '@app/themes/myTheme',
'baseUrl' => '@web/themes/myTheme',
'pathMap' => [
'@app/views' => '@app/themes/myTheme',
],
],
],
],
は、しかし、私は「/var/www/html/myProject/app/frontend/views/site/index.php」ビューファイルが存在しないというエラーを取得保管???
私もそう私の質問があるHow to change default view path in Yii2?
public function getViewPath()
{
return Yii::getAlias('@web/themes/myTheme/site');
}
に基づいて、コントローラ内部でこの機能を入れてみました: 1.どのように私はビューのデフォルトのパスを変更できますか? 2.セッション中にcommon/config/main.php設定を変更できないので、私は自動的にそれを行うことができますか?
サイトコントローラ
class SiteController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['index'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['index'],
'allow' => true,
'roles' => ['@'],
],
],
],
];
}
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
/**
* Displays homepage.
*
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
}
あなたは私にあなたのコントローラを表示することができますか? – hesselek
シンプルコントローラ – leila