There are few ways you can pass variables to all templates independently
from what the controller is providing.
The most simple one is to use tg.tmpl_context which is meant to be a
container for variables that should be shared by all templates, as
tmpl_context is always available to all templates.
Otherwise you can set a variable_provider option in app_cfg, which can be
set to a function (must return a dict) that will be executed when rendering
the template to provide additional variables.

In regard of editing the pages content themselves. The most simple
solutions are to add the section in master.xhtml with a py:if that makes it
visibile only when in the admin, or to use template patches (
https://github.com/TurboGears/tgext.pluggable#patching-templates ) to patch
the templates with extra sections.
Otherwise Admin obviously support changing the expositions of the
controllers and replacing the templates, but that will require providing
new templates instead of just patching the existing ones.

On Fri, Feb 28, 2020 at 6:13 PM Mikhail <push....@gmail.com> wrote:

> Hello!
>
> I have master.xhtml with some kind of menu:
> <ul class="menu">
>     <li py:for="pg in pages">
>         <a href="/pages/${pg.name}" py:content="pg.title">Page</a>
>     </li>
>
> </ul>
>
> Now when I am using AdminController I get error "builtins.NameError".
> NameError: name 'pages' is not defined
>
> *Question*: Is there a way to pass pages to AdminController's output?
>
> As workaround I tried to use custom layout without menu:
> class CustomAdminConfig(TGAdminConfig):
>     default_index_template = 'admin.xhtml'
>
> class RootController(BaseController):
>     admin = AdminController(model, DBSession, config_type=
> CustomAdminConfig)
>
> But it seems that admin.xhtml only applied to /admin page, not any of
> subpages such as /admin/users. And I prefer to have menu on all pages,
> including admin.
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to turbogears+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/turbogears/5a5db6e0-ab34-4a4d-8d32-82f622c5db7c%40googlegroups.com
> <https://groups.google.com/d/msgid/turbogears/5a5db6e0-ab34-4a4d-8d32-82f622c5db7c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to turbogears+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/turbogears/CAJfq2JEqtmUnUphy0CrsZXA-Ofkj9u6XDRDZmz5Bob9%3DnwSpvw%40mail.gmail.com.

Reply via email to