I tried your second suggestion, putting a code block into the corresponding template and it worked just perfectly. I figured this would be the easiest hence fastest way of solving the issue and it turned out to be just two lines of (very simple, straight forward) code. Now that's what I like to see ! Thank you ! :-)
Amnu On Oct 19, 12:56 am, "Diez B. Roggisch" <[email protected]> wrote: > On Oct 18, 2010, at 9:10 PM, Amnu wrote: > > > > > Hi Folks, > > > In my application's master template I have a menu which displays > > categories. These are not static but fetched from the database and > > passed in via the controller. Currently, in order for this menu to > > work propperly I have to fetch those entries in every single function > > that exposes some template, since I want that "master menu" to be > > displayed correctly. > > I can't just make the categories persistent entries or even hard coded > > into the templates, since they shall be changed dynamically. But I > > really do not want to spam my controller by adding that category > > information into every single "return dict(...)" call. > > Is there some way to have the master template always pull that > > information from the (root) controller by itself, automatically ? In > > other words, can I make the controller send that information into the > > current template (the one being exposed by the current function) > > automatically ? > > I'm not too much into templates, since that's simply not my part of > > the application (more controllers and db). Some hint to get me in the > > right direction would be appreciated. > > You have to buckle up and get into templates I'd say. > > There are various ways to tackle this, but all involve template programming > to some extent. > > You need to make the list of categories available in the master-template. > AFAIK, there are three ways to do that: > > - override the __call__-method in BaseController to inject a category list > in all calls > - get them in a python-block in master.html (at least in genshi that works) > - provide them using the variable_providers, which is a callable will be > invoked in every call and stuffes things into the template context. > > I prefer the latter. Unfortunately, I don't know out of my head where to > register these out of my head. If looking for them doesn't help you, ask > again. > > Diez -- You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en.

