Hi there,

I just come across this old post. I solve this problem in a slightly 
different way. With all the same *.mobile views ready, I just explicitly 
use ".mobile" extension name as my visiting url, such as 
http://.../app/controller/action.mobile, therefore I don't need those "if 
is_mobile" code snippet in my every controller functions.

Hope that helps.

Regards,
Ray


On Tuesday, June 28, 2011 4:21:26 PM UTC+8, demetrio wrote:
>
> Sorry, i sent the message incomplete:
>
> Hi!
>
> I'm using jQueryMobile to make the "mobile skin", and the way that i do
> is this:
>
> if is_mobile and request.extension == "html" :
>         #Its mobile             
>         response.view = "%s/%s.%s" % (request.controller,
> request.function, "mobile")
>         if not os.path.exists(os.path.join(request.folder, 'views',
> request.controller, request.function+".mobile")):
>             response.view = '%s.%s' % ("generic", "mobile") 
>
>
> The 'request.extension == "html"' condition is because if you
> use .load, .json extensions or so, it can crash
>
> With this code, you only have to make ".mobile" extensions of your
> views:
>
> for example if you have:
>
> layout.html
> generic.html
> controller/funct1.hmtl
> controller/funct2.html
>
> You only have to make the views:
>
> layout.mobile
> generic.mobile
> controller/funct1.mobile
> controller/funct2.mobile
>
> If you keep your editor's syntax highlighting maybe you can change
> ".mobile" extension with ".mobile.html" (editing the code that i pasted
> at the begginig too, to make this change work)
>
> I hope this solution will be useful
>
> El lun, 27-06-2011 a las 16:28 -0700, Luis Goncalves escribió:
> > Hello!
> > 
> > I need to customize my views so that they look good on a computer
> > screen and on a smart phone.
> > 
> > One way to do so, It think, is to have separate layout definitions and
> > then do something like:
> > 
> > {{if session.platform == 'mobile':}}
> > {{extend 'mobile-layout.html}}
> > {{else:}}
> > {{extend 'desktop-layout.html'}}
> > {{pass}}
> > 
> > This does not seem to be working -  I get lots of syntax errors (can't
> > even figure out where they are!)
> > 
> > Is this approach wrong?   Is it possible to have a conditional
> > "extend" ?
> > 
> > Is there a smarter/better way to make the view rendering platform
> > dependent?
> > 
> > Thanks,
> > Luis.
>
>
>

-- 



Reply via email to