Heres my solution - works a treat:

#Controller.py
if request.vars.get('printMode', None):
    response.layout = 'layoutPrint.html'
    printMode=True
else:
    response.layout = 'layout.html'
    printMode=False


# all views
{{extend response.layout}}

I use the printMode Boolean to detemine whether to display the
"Printer Friendly" link on the page.

Many thanksThadeus.


On Aug 13, 11:07 pm, Paul Gerrard <p...@gerrardconsulting.com> wrote:
> I suspected that I had done something that worked 'by chance' and the
> new version caught me out. :)
>
> Thanks for the tip - I'll try it.
>
> Paul G
>
> On Aug 13, 5:30 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
>
>
>
> > Odd... it should *technically* extend from the last seen version of
> > extend regardless of where it is located.
>
> > Also, I don't understand how this worked pre 1.80 either.
>
> > The templates are parsed before any of the python statements are even
> > known or executed, this just should have never worked.
>
> > I also don't see an obvious way of making this work, since the
> > template would have to know the context of python as its parsing.
>
> > Try re-designing how you handle this.
>
> > in controllers.py or models.py
> > # Just assign a variable to the name of the template you want to extend
> > response.printMode = 'layoutPrint.html' if
> > request.vars.get('printMode', None) else 'layout.html'
>
> > in templates.py
> > {{extend response.printMode}}
>
> > --
> > Thadeus
>
> > On Fri, Aug 13, 2010 at 10:31 AM, Paul Gerrard
>
> > <p...@gerrardconsulting.com> wrote:
> > > Hi,
>
> > > I have a lot of views in my system with the following code at the top
> > > of the view html:
>
> > > {{import string}}
>
> > > {{if request.vars and 'printMode' in request.vars:}}
> > > {{printMode=request.vars['printMode']}}
> > > {{else:}}
> > > {{printMode=None}}
> > > {{pass}}
>
> > > {{if printMode:}}
> > > {{extend 'layoutPrint.html'}}
> > > {{else:}}
> > > {{extend 'layout.html'}}
> > > {{pass}}
>
> > > ... the rest of the layout HTML etc.
>
> > > In version 1.79.1 it worked fine. If there was no printMode var in the
> > > query string, I got the standard layout. If there was a PrintMode var,
> > > I got a simpler layout without the headers, menus etc. for printing..
>
> > > In 1.82.1 it doesn't work at all. It looks like neither layout is
> > > invoked and all my pages look terrible with no formatting (because no
> > > CSS) at all.
>
> > > Any suggestions (or I'll ave to regress back to 1.79.1). :O(- Hide quoted 
> > > text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Reply via email to