Execute a different controller method


I am making a mobile version of my site and I need to execute a different method sometimes.

So say someone goes to actionIndex() I need it to execute actionIndexMobile() how is this possible?

I know the code to test for mobile browsers I just need the code to make it switch method based on a condition.

Preferably this code will go in the parent "Controller" class.

I could just put an IF statement in each method and redirect it but that is not what I am looking for, I am looking for more of a global solution so the switch code will need to go in something like the components "Controller" class which extends CController or some config file or something.


Did you try using filters? You could plug your conditions in there. See http://www.yiiframework.com/doc/guide/1.1/en/basics.controller#filter