On Wed, May 28, 2008 at 3:50 AM, Christoph Haas <[EMAIL PROTECTED]> wrote: > Hi, Antonia... > > first of all: please don't hijack threads. Start a new thread if you want > to post to this list. Don't just reply to a random posting. > > On Mittwoch, 28. Mai 2008, Antonio Beamud Montero wrote: >> How I can get the controller name in the actual template context. For >> example, a site.mako template used by several controllers, I want to >> show the controller name with something like this: >> >> ${c.name} >> >> It's possible or I must define a property for every controller with it's >> name? > > The routes dictionary contains the information you are after: > > request.environ['pylons.routes_dict'] > > You cann add a "def __before__(self)" in the lib/base.py and fill a > template variable with it to be used in the templates: > > c.routes = request.environ['pylons.routes_dict'] > > That would allows you to access the current controller's name in the > template as: > > ${c.routes['controller']}
Actually, it's easier than that: ${c.controller} Routing variables are automatically added to 'c'. -- Mike Orr <[EMAIL PROTECTED]> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---