I want to display a mobile view instead of the normal view script.
Let's take for example this action /my_module/my_controller/my_action.
When I call it, based on some headers processing I know that user agent is a mobile device.
Then I set the main layout to be a mobile-specific layout.
I do that like this and it works fine: Zend_Layout::getMvcInstance()->setLayout('mobile');
But in my controller or somewhere else I want to override the default view file my_action.phtml
on something like my_action_mobile.phtml
.
How that could be done considering that in some of my views I am using the action helper as this: <?php echo $this->action("index", "index", "items")?>
or is some of my action I have a _forward like this: $this->_forward("index", "auth", "default");
I have tried with setViewSuffix('mobile')
and with several file name variants as: my_action.mobile.phtml, or setViewSuffix('mobile.phtml')
and the file called my_action.mobile.phtml and others, resulting in a blank page - no error, nothing. ( i have no ideea why because it is set to display the thrown errors )
Also I have tried with contextSwitching but it disables my main layout - i do not want this - and it feels like it does not handles properly the action view helper. ( a view rendered in another )
I would appreciate any suddgestion. Thank you!
There is an awful lot of information on the subject. For starters get youself throught http://static.zend.com/topics/Mobile-web-app-with-ZF.pdf
In a nutshell, you should use ContextSwitch.