Hi everybody,
I have Url rules in my main.php
'/'=>'/social',
'<community:(ukuya|mspc)>' => '/social',
'<community:(ukuya|mspc)>/<module:\w+>/' => '<module>',
'<community:(ukuya|mspc)>/<module:\w+>/<controller:\w+>/' => '<module>/<controller>',
'<community:(ukuya|mspc)>/<module:\w+>/<controller:\w+>/<id:\d+>'=>'<module>/<controller>/view',
'<community:(ukuya|mspc)>/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
'<community:(ukuya|mspc)>/<module:\w+>/<controller:\w+>/<action:\w+>/<id:\d+>'=>'<module>/<controller>/<action>',
I have to set errors for wrong community or module.
my error action:
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'home/error',
),
when I type
domain.com/somethin or
domain.com/ukuya/somethin
this gives me same error message.
but I need, error message like
Wrong community or
Wrong module
any idea?
Hi.
I don’t know if this is the best solution, but it’s an idea:
public function actionError()
{
if($error=Yii::app()->errorHandler->error)
{
if(!in_array($_GET['community'], array('ukuya','mspc')))
$error['message']='Wrong community';
$this->render('error', $error);
}
}
Thank you for your reply.
I think you’re right.
But there has to be best solution for this.
Anyways I did somethin like this, it is working right now
if(isset($error['code']) && $error['code']===404)
{
if(strpos($error['message'], "Unable to resolve the request") === 0)
{
$error['message'] = $this->checkError(
$error['message'],
Yii::app()->request->requestUri
);
}
}
$this->render('error', $error);
checked error message in my own function.