[Zope-Coders] Re: [ZC] 23/ 2 Comment "Small CMFDecor breadcrumbs fix"
Gary Poster
Gary Poster" <garyposter@earthlink.net
Thu, 8 Nov 2001 14:05:23 -0500
Acknowledged. It is now reported on the CMF collector. Sorry to bother you
(collectively).
I would close the listing on this Zope core collector if I could, but...I
can't.
Thanks
Gary
----- Original Message -----
From: "Collector: Zope Bugs and Patches ..." <zope-coders@zope.org>
To: "Gary Poster" <garyposter@earthlink.net>; "klm" <klm@zope.com>; "Brian"
<brian@digicool.com>
Sent: Thursday, November 08, 2001 1:38 PM
Subject: [ZC] 23/ 2 Comment "Small CMFDecor breadcrumbs fix"
> Issue #23 Update (Comment) "Small CMFDecor breadcrumbs fix"
> Status Pending, Zope/bug+solution low
> To followup, visit:
> http://new.zope.org/Collector/23
>
> ==============================================================
> = Comment - Entry #2 by ajung on Nov 8, 2001 1:38 pm
>
> I think this bug report should go to the CMF collector.
> This collector is for the Zope core only.
>
> Andreas
> __________________________________________________
> = Request - Entry #1 by Anonymous User on Nov 8, 2001 1:11 am
>
> CMFDecor breadcrumbs script is currently directly addressing portal url
and properties tools, instead of using the CMFCore utils.py getToolByName
function. As I understand it, this direct call breaks (or at least hinders)
the ability to use arbitrary replacement portal tools in the CMF.
>
> Unfortunately, in order to import the getToolByName function, it seems the
script must be external. I modified the original script slightly to create
the following External Method (which I named CMFbreadcrumbs.py and placed in
my Extensions folder, but whatever):
>
> >from string import join
> >from Products.CMFCore.utils import getToolByName
> >
> >def CMFBreadcrumbs(include_root=1, context=None):
> > portal_url_tool=getToolByName(context, 'portal_url')
> > portal_properties_tool=getToolByName(context, 'portal_properties')
> > result = []
> > portal_url = portal_url_tool()
> >
> > if include_root:
> > result.append( { 'id' : 'root'
> > , 'title' : portal_properties_tool.title()
> > , 'url' : portal_url
> > }
> > )
> >
> > relative = portal_url_tool.getRelativeContentPath( context )
> > portal = portal_url_tool.getPortalObject()
> >
> > for i in range( len( relative ) ):
> > now = relative[ :i+1 ]
> > obj = portal.restrictedTraverse( now )
> > if not now[ -1 ] == 'talkback':
> > result.append( { 'id' : now[ -1 ]
> > , 'title' : obj.Title()
> > , 'url' : portal_url + '/' + join( now,
'/' )
> > }
> > )
> >
> > return result
>
> you can call this directly from dtml or zpt; being lazy, I instead called
this breadcrumbsScript in my Zope and then customized the current
breadcrumbs Python Script to be simply this one line:
>
> >return container.breadcrumbsScript(context=context)
>
> That way I didn't have to change the main_template ZPT in the slightest.
>
> Small thing, but hey, I did the minimal work already so I thought you
might want it.
> ==============================================================
>