When I first read about subdirectories I saw this structure:
views/default/index.html
views/default/mobile/index.html
views/default/tablet/index.html
If no mobile/tablet directory or index.html is found it defaults to
/views/default/index.html
Kenneth
On Jul 23, 2011, at 12:36 PM, Ross Peoples wrote:
That thought had occurred to me about mobile phones vs tablets, but I didn't
want to get too complex with this right away. However, you are correct that
many sites have an iPhone/mobile site, and iPad site, and a desktop site. I
think I'll try to expand my patch to replace request.is_mobile with
request.browser_class, which could equal 'desktop', 'mobile', or 'tablet'. A
request from an iPad would first check for 'tablet' views, then 'mobile' views,
and finally 'desktop' views. How does that sound?
As for the directory structure, I suppose we could do something like this:
At this stage I don't have enough of a sense of what structure makes the most
sense, so my comments aren't that well informed.
Might it make sense for the mobile/&c subdirectories to live inside each
controller directory instead? Probably not, but I'm not sure of the reasons.
I also wonder if it might make sense to default to the appropriate top-level
view if a particular mobile view isn't available.
views/
_mobile/
default/
other_controller/
_tablet/
default/
other_controller/
default/
other_controller/
Or even put the devices into an main '_devices' folder:
views/
_devices/
_mobile/
...
_tablet/
...
default/
other_controller/
The only issue I'm having with this is with the layouts. In order for this to
work with byte compile, I actually had to turn the layout.html file into this:
{{if is_mobile:}}
<!-- All mobile HTML -->
{{else:}}
<!-- rest of original layout.html file -->
{{pass}}
I tried breaking it into desktop.html and mobile.html, then in layout.html:
{{if is_mobile:}}
{{include 'mobile.html'}}
{{else:}}
{{include 'desktop.html'}}
{{pass}}
Unfortunately, in the desktop.html or mobile.html, the {{include}} line that
includes the view content is ignored, so I had to put everything into a single
layout.html file.
I'm out of my depth here. Perhaps Massimo or someone else could comment on what
makes most sense here.