[Zope-CMF] Re: ZPT page in breadcrumbs

altkey myaltkey at msn.com
Thu Mar 25 00:12:13 EST 2004


Here's a bread crumbs script fragement that we're using. It'll give you 
a set of links representing the url-path to the object you are 
displaying .... hope it is useful

###############################
# defaultBreadcrumbs
###############################
def defaultBreadcrumbs():
   request = context.REQUEST
   result = []

   # Get the url of the portal in a safe and portable manner
   portal_url = context.portal_url()

   # This adds the root of the portal path to the breadcrumbs
   # it can be overidden when invoked

   if include_root:
     result.append( { 'id'    : 'home'
                    , 'title' : context.portal_properties.title_or_id()
                    , 'url'   : portal_url } )

   # Get the relative path of where the user is (path) as compared to the
   # root of the portal and return as a path object (array of names making
   # up each part of the path

   relative = context.portal_url.getRelativeContentPath( context )
   portal = context.portal_url.getPortalObject()

   # Step through each element in the relative path array
   for i in range (len(relative)):
     # get each path object that makes up the path
     now = relative[ :i+1 ]

     # traverse the path and actually get the object
     obj = portal.restrictedTraverse( now )

     # if we get something that is not 'index_html' ( in other words
     # a default render method ) then append the results to the breadcrumbs
     # objects array. Don't show MenuFolders  - they are for grouping,
     # not navigation.
     if (now[-1] != 'index_html' and obj.Type() != 'MenuFolder'):
       result.append({ 'id'    : now[-1]
                     , 'title' : obj.title_or_id()
                     , 'url'   : portal_url + '/' + join (now, '/') })

   zidD = zidDictionary(request)
   if zidD:
     result.append(zidD)
   return result


Antony Higgs wrote:
> Hi
> 
> Is it possible to make a ZPT page appear in the breadcrumbs?
> 
> I have a ZPT page at the root of our site and when you view the page the 
> breadcrumbs just display 'home'
> 
> What I want is the breadcrumbs to be...
> 
> 'link to home' > ZPT page title
> 
> 
> thanks
> 
> Antony
> 
> 
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF at zope.org
> http://mail.zope.org/mailman/listinfo/zope-cmf
> 
> See http://collector.zope.org/CMF for bug reports and feature requests
> 





More information about the Zope-CMF mailing list