Hello, all!
My project don’t see layout. I can’t understand why.
This is my config/main.php
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'test',
'defaultController' => 'index',
'modules'=>array(
'default'=>array(
'defaultController'=>'index',
'layout'=>'main',
)
),
'import'=>array(
'application.models.*'
),
// application components
'components'=>array(
// uncomment the following to enable URLs in path-format
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'<controller:\w+>/<action:\w+>' => 'default/<controller>/<action>',
'<controller:\w+>' => 'default/<controller>',
'<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
'<module:\w+>/<controller:\w+>' => '<module>/<controller>',
'' => 'default',
)
),
'errorHandler'=>array(
'errorAction'=>'default/index/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
)
),
),
),
'params'=>array(
// this is used in contact page
'adminEmail'=>'asdfasdf@ya.ru',
),
'onBeginRequest' => function() {
if (Yii::app()->request->isAjaxRequest)
header ('Content-type: application/json');
}
);
My default module:
<?php
class DefaultModule extends CWebModule {
public function init() {
}
public function beforeControllerAction($controller, $action) {
if(parent::beforeControllerAction($controller, $action)) {
$role = User::getInstance()->getUserRole();
$cName = $controller->getId();
$aName = $action->getId();
$rules = array(
'works' => array(
'list' => array('guest', 'author', 'client', 'moderator'),
'albums' => array('guest', 'author', 'client', 'moderator'),
'profile' => array('author', 'client', 'moderator')
),
'author' => array(
'works' => array('guest', 'author', 'client', 'moderator')
),
'index' => array(
'login' => array('guest', 'author', 'client', 'moderator'),
'logout' => array('author', 'client', 'moderator'),
'authorise' => array('guest')
)
);
if (
isset($rules[$cName][$aName]) &&
in_array($role, $rules[$cName][$aName])
) {
return true;
}
else {
echo "Permission to path $cName/$aName denied.";
return false;
}
}
else
return false;
}
}
If I put
echo $this->layoutPath;
in DefaultModule I see /var/www/protected/modules/default/views/layouts
And in this directory I have file main.php. It’s my layout. When I visit any controller/action project don’t use layout.
Can u help me? Where I can see log error of finding layout or where I can find supplementary information.
Every controllers does not have definition of layout in init() method.
Thank you very much.