On the server side, request.user_agent() returns info about the user agent, 
and request.user_agent().is_mobile indicates whether it's a mobile device. 
You can also decorate a function with @mobilize, and when it's a mobile 
client, it will automatically change the view from func.html to 
func.mobile.html, so you can have a separate mobile view (which can extend 
an alternative layout). I suppose you could also specify a variable in the 
{{extend ...}} to extend different layouts for mobile and non-mobile 
requests, but in that case, you won't be able to byetcode compile the views 
(because the view being extended must be known at compile time).

You can also do things on the client side with CSS media queries and JS. 
For example, the new 'welcome' app (in trunk -- demo here: 
http://tests.web2py.com/welcome/) uses Skeleton 
(http://www.getskeleton.com). If you make your browser window skinny, 
you'll see how the layout changes (dynamically) to accommodate the narrow 
screen.

Anthony

On Saturday, November 26, 2011 9:10:50 PM UTC-5, VP wrote:
>
> Hi,
> I know web2py has a seemingly very useful plugin for jquery mobile.  I
> am wondering what everyone does for apps that are supposed to be
> tailored for both PCs and mobile devices.  At the simplest level,
> let's say there are two layouts that need to be switched depending on
> which platforms.  How do we do this efficiently in web2py?
>
> Further, in addition to layouts, different controllers might be needed
> for different platforms too.  How do we do this efficiently?
>
> Thanks.
> VP
>
>

Reply via email to