response.view does not change the layout template -- it changes the
template of the action being called (which typically extends a layout
template). When you set response.view = 'public_layout.html', you are
telling web2py to use public_layout.html as the view for the index function
instead of using /views/default/index.html (so index.html never gets
called). Instead, in index.html, you can do something like:
{{extend 'public_layout.html' if [some condition] else 'private_layout.html'
}}
But keep in mind that you won't be able to compile any views that include
expressions in the {{extend ...}} statements, as above.
Anthony
On Monday, November 18, 2013 5:55:53 PM UTC-5, Mark Graves wrote:
>
> Hey guys,
>
> Two questions:
>
> So I've got a public facing site and a private site, which have different
> layouts.
>
> In the past, I used one layout.html and blocks of if statements to include
> stuff.
>
> In terms of performance what would be the difference between that and
> response.view?
>
> Also, I was having trouble with blocks and response.view.
>
> For example in "public.py" controller:
>
> def index():
> response.view = 'public_layout.html'
> return dict()
>
> And view public/index:
> {{extend 'public_layout.html'}}
>
> {{include 'default/carousel.html'}}
>
> I'm not getting the carousel included. Do I also have to put:
>
> {{extend 'public_layout.html'}}
>
> in carousel.html?
>
> Thanks
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.