On 6/16/07, wongobongo <[EMAIL PROTECTED]> wrote:
> How did you implement the breadcrumbs?
It's a pattern I've used for years. c.crumbs is a list of (url,
label) pairs for each link except the first ("Home"), which is always
shown. Most controllers can leave it at the default, []. Those that
are third-level put the second-level link in the list; those that are
fourth put the second and third in the list, etc. A special value
None suppresses the breadcrumbs completely.
Normally the last link would be the parent page, but the client
insisted on an additional non-clickable link for the current page, so
I implemented that with c.page_crumb.
=== lib/base.py
def __begin__(self):
c.crumbs = []
=== lib/helpers.py
def link(label, *url_for_args, **url_for_kw):
url = url_for(*url_for_args, **url_for_kw)
return link_to(label, url)
=== templates/site_mako.html
% if c.crumbs is not None:
${h.link("Home", "home")}
% for url, label in c.crumbs:
>> ${h.link_to(label, url)}
% endfor url, label
% if c.page_crumb:
>> ${c.page_crumb}
% endif c.crumbs
It uses CSS classes for the coloring, but I'd have to look at the
source to remember which tags I used. :)
=== Most controller actions are top-level pages
# Leave c.crumbs at default.
=== An Entry page is third-level
c.crumbs = [(h.url_for("incident", orr_id=orr_id), "Incident")]
=== A hypothetical fourth-level page
c.crumbs = [("second_url", "Second Label"), ("third_url", "Third Label")]
--
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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---