Thanks Jeff,

I made a quick widget out of it. I'm sure its not up to snuff... but it
works for me.

I added the widget to the global space and reference it in my master.kid.
The
thread that mentions register_widgets provided the method for doing this.
Now all my pages have the breadcrumb widget automatically.
Very cool. Thanks again,

Nicky

On 12/19/06, Jeff Hinrichs - DM&T <[EMAIL PROTECTED]> wrote:
>
>
> On 12/19/06, Jeff Hinrichs - DM&T <[EMAIL PROTECTED]> wrote:
> > > I've taken your input and modified the code. In fact, I built a
> > > breadcrumbs.py module that is generic enough to work out of the box
> > > along with the kid template snippet.  I'd be happy to post it and if
> > > it would add anything I could post it to the wiki.  I am just
> > > finishing up with the epydoc strings for the module.
> > >
> Well I didn't get any feedback about posting it to the wiki or such
> but I felt it might help some else out so I set it up on google.
>
> http://code.google.com/p/tg-breadcrumbs/
>
>
> enjoy and thanks
>
> -j
>
> >
>


-- 
--
Nicky Ayoub
G-Mail Account


--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---
#______________________________________________________________________________
# Bread Crumbsfrom turbogears.widgets.forms import  Widget
from turbogears import controllers
from turbogears.view import variable_providers
from cherrypy._cputil import get_object_trail

class Breadcrumb(Widget):
    template = """
<div xmlns:py="http://purl.org/kid/ns#"; >
<span py:for="href_link,href_text in tg.breadcrumbs()"> / <a href="${href_link}">${href_text}</a></span>
</div>
""" 
    def __init__(self, **kw):
        super(Breadcrumb, self).__init__(**kw)
        variable_providers.append(add_breadcrumbs)
  
def create_breadcrumbs():
    """Return link information for constructing bread crumb navigation."""
    cherry_trail = get_object_trail()
    href = '/'
    crumbs = [(href, 'home')] 
    for item in cherry_trail:
        # item[0] is the name you use in the URL to access the controller.
        # item[1] is the actual controller
        if isinstance(item[1],
                (controllers.Controller, controllers.RootController)):
            if item[0] != 'root':
                href = "%s%s/" % (href, item[0])
                crumbs.append([href, item[0]])
    return crumbs

def add_breadcrumbs(variables):
    variables["breadcrumbs"] = create_breadcrumbs
    
breadcrumbs = Breadcrumb()

Reply via email to