簡體   English   中英

使用默認控制器和默認操作在yii應用程序中設置主頁?

[英]Setting Home Page In yii Application With Default Controller And Default Action ?

您好,我正在嘗試更改yii應用程序的默認控制器。 我在線上找到了多個答案,但所有答案都需要在main.php中更改此功能,但是我找不到要修改的功能。 這是功能

return array(
    'name' => 'Web Application',
    'defaultController' => 'HomePages ', 

);

當我將這個函數放到下面時,第一個返回數組就這樣消失了:

<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'HomePages',

    return array(
    'name' => 'Web Application',
    'defaultController' => 'HomePages ', 

);


    // preloading 'log' component
    'preload'=>array('log'),

    // autoloading model and component classes
    'import'=>array(
        'application.models.*',
        'application.components.*',
    ),

我找不到“核心默認控制器(站點/索引)”之類的東西,該如何正確執行?

您應該只將值放在Yii返回數組中,而不要將2個返回數組放在同一件事中

return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'HomePages',
    'defaultController' => 'HomePages', 
);

並確保刪除HomePages一詞后的多余空間,並將控制器命名為HomePages

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM