B
B
bor12014-03-08 05:37:21
Yii
bor1, 2014-03-08 05:37:21

How to organize checking for the presence of a controller and an action in Yii?

When accessing a non-existent url, it gives an error: Page Not Found Unable to resolve the request "xxx".
The question is, if it is possible in yii to make your own check and set the display of the site page instead of an error message? What interests me the most is where this check should be.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
p4s8x, 2014-03-08
@p4s8x

If we are talking only about errors, then in the config you write errorHandler

return array(
    …
    'components'=>array(
        'errorHandler'=>array(
            'errorAction'=>'site/error',
        ),
    ),
);

Accordingly, an action called Error from the Site controller will be called, and you can handle this error in any way and display your page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question