Code Demo for beforeAction

{Code}

public function beforeAction()
{
    if($this->action->id == 'index')
    { 
        //TODO
    }
}

{BoyLee Said}

The day before yesterday, I try to use beforeAction to execute some code before actionIndex. You can use filter to do some like this too.

So I got this code from JianZhang's help, thanks again.