[Zope-CMF] Breadcrumbs

Chris Withers chrisw@nipltd.com
Mon, 4 Jun 2001 00:25:32 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_08AE_01C0EC8C.DDEC4780
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Well, having mentioned I found navigation difficult, here's a bit of a
solution in the form of easily includable breadcrumbs :-)
They look just likes the ones below the tabs in the right-hand pane of the
management interface.

Either put the attached script in a skins directory on disk or add it as a
normal PythonScript in one of your custom skins folders.

Then, whenever you want an object's breadcrumbs, just do:

<dtml-var breadcrumbs>

...I've used it in the folder_contents method of my refactored CMFDefault
skins, but there's no reason not to use it in standard_html_header and have
it appear on all your portal contents pages.

cheers,

Chris

PS: I'm quite chuffed with the folder view in my refactored CMFDefault,
hopefully I'll get the rest of the 'generic' layer done soon so I can mail
out a .zip :-)


------=_NextPart_000_08AE_01C0EC8C.DDEC4780
Content-Type: text/plain;
	name="breadcrumbs.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="breadcrumbs.py"

## Script (Python) "breadcrumbs"
##parameters=
##title=Returns linked breadcrumbs for the current location
from string import split,join
# Might need a slight url quoting shuffle if
# getRelativeUrl starts url-quoting :-S
from Products.PythonScripts.standard import url_quote
portal_url = context.portal_url

path = portal_url.getRelativeUrl(context)
if not path:
    return 'Root of %s' % context.portal_properties.title()

Type = getattr(context,'Type','Object')
if callable(Type):
    Type=Type()
    
# Also assuming folderish content, fair enuff for now :-)
pattern='<a href="%s/folder_contents">%s</a>'
url = portal_url()
steps = split(path,'/')
breadcrumbs = [pattern % (url,context.portal_properties.title())]
last = steps.pop()

for step in steps:
    url = '%s/%s' % (url,url_quote(step))
    
    breadcrumbs.append(pattern % (url,step))
breadcrumbs.append(last)

return '%s at %s' % (Type,join(breadcrumbs,'/'))
------=_NextPart_000_08AE_01C0EC8C.DDEC4780--