Back to index

plone3  3.1.7
breadcrumbs.py
Go to the documentation of this file.
00001 ##parameters=include_root=1
00002 ##title=Return breadcrumbs
00003 ##
00004 from Products.CMFCore.utils import getUtilityByInterfaceName
00005 from Products.CMFCore.utils import getToolByName
00006 from Products.CMFDefault.utils import Message as _
00007 
00008 ptool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
00009 utool = getToolByName(script, 'portal_url')
00010 portal_url = utool()
00011 result = []
00012 
00013 if include_root:
00014     result.append( { 'id'      : _(u'root')
00015                    , 'title'   : ptool.title()
00016                    , 'url'     : portal_url
00017                    }
00018                  )
00019 
00020 relative = utool.getRelativeContentPath(context)
00021 portal = utool.getPortalObject()
00022 
00023 for i in range( len( relative ) ):
00024     now = relative[ :i+1 ]
00025     obj = portal.restrictedTraverse( now )
00026     if not now[ -1 ] == 'talkback':
00027         result.append( { 'id'      : now[ -1 ]
00028                        , 'title'   : obj.Title()
00029                        , 'url'     : portal_url + '/' + '/'.join(now)
00030                        }
00031                     )
00032 
00033 return result