Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle mobile devices in Zend Framework?

I've taken over a nightmare of a project! I'm moving a very poorly written site and moving it slowly into a Zend Framework application. Unfortunately I have no time to do the remedial work to make this even bearable (maybe a model or two). I have now been told that it is soon to have mobile version of the site and the proposal has been to clone the old site and work with that. In an attempt to not work on different versions of the same crap and buy myself some time I proposed that the ZF site should handle it all.

Is it awful practice to use Zend_Http_UserAgent to detect then simply load an alternative layout and content?

I was inclined to use two modules at first but I've had a bit of trouble with ACLs in modules.

Any alternative suggestions are welcome!

Cheers

like image 908
piddl0r Avatar asked Apr 04 '11 16:04

piddl0r


3 Answers

With Zend Framework 1.11 zend introduced the wurfl adapter which is based on Zend_Http_UserAgent.

It allows you to detect mobile devices and bootstrap different layouts. There is a HOW TO on youtube that came with the zend newsletter december 2010: http://www.youtube.com/watch?v=_A8yg73tqOY

You don't have to use different modules! Just different layout files!

like image 191
UpCat Avatar answered Oct 06 '22 02:10

UpCat


if (Zend_Http_UserAgent_Mobile::match($_SERVER['HTTP_USER_AGENT'], $_SERVER)) {

}

like image 29
Oleg Kravchenko Avatar answered Oct 06 '22 02:10

Oleg Kravchenko


A good starting point would be to look at responsive design techniques with css. There are many tutorials out there just google "responsive design" and perhaps you can refactor the existing layout.

like image 35
user466764 Avatar answered Oct 06 '22 02:10

user466764