Question

I'm developing a mobile site using Zend framework, and the site has two possible output formats (WML and XHTML). I'm using the same models and controllers, and then just setting which view to render with in the controller. At the moment, this is decided on by the HTTP Accept header. This needs to be definable in the URL as well. The way I'd like to do this is with a URL like the following: http://example.com/wml/controller/action http://example.com/xhtml/controller/action

What's the best way to achieve this using the Zend Framework?

Thanks!

Was it helpful?

Solution

You need to look at Context Switching under the Action Helpers section. You can pass a format parameter via the URL and it will change the type of output that comes from the action. You should be able to easily create a Context class for WML.

So instead your URL looks like this:

http://www.example.com/controller/action/format/wml

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top