maybe it can help u.

# web.py 0.23
# code.py
web.template.Template.globals['is_login']=people_model.is_login
...

# index.html

                <div class="box">
                    <h5>Meta</h5>
                    <div class="box_content">
                        $if config().allow_reg:
                            <p><a href="/people/new">reg</a></p>
                        $if is_login():
                            <p><a href="/logout">logout</a></p>
                            <p><a href="/entry/admin">admin</a></p>
                        $else:
                            <p><a href="/login">login</a></p>
                        <p><a href="/rss">RSS</a></p>
                    </div>
                </div>

...

On Thu, Feb 19, 2009 at 8:35 PM, matatk <[email protected]> wrote:

>
> I have got a "site layout" template set up as per
> http://webpy.org/cookbook/layout_template
> .  There are some variables that I would like to display through the
> site layout template so that they're visible on all pages.  However,
> they would not be relevant to the individual page templates so I don't
> want to pass these variables to each template individually, as that
> would lead to much repeated code.
>
> An example of such information would be site structure trail, like the
> one webpy.org uses.  It's not of importance to the individual page
> templates, rather the site layout template.  Maybe even the currently
> logged-in user's name (so that the site layout template could display
> this, or a "log in" link).
>
> It would be very helpful if I could point webpy to a dict of variables
> that I would like included in the site layout template as well as
> "content".  Such a dict could be updated whenever is appropriate to my
> app.  Inside the site layout template I could say $dict.varname to
> refer to them.  Ideally I would not have to pass this dict to each
> call of render(), as that's logically aimed at individual pages, not
> the site layout page.
>
> Is this possible?  Many thanks for your time and any advice you may be
> able to give.
> >
>


-- 
百才招聘(baicai.com).产品部
Gtalk: [email protected]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to