def isDefaultPage(self, obj, request=None): # Finds out if the given obj is the default page in its parent folder. # Uses the lookup rules of Plone. Lookup happens over a view, for which # in theory a different implementation may exist. if request is None: request = self.REQUEST return check_default_page_via_view(obj, request)
def breadcrumbs(self): context = aq_inner(self.context) request = self.request container = utils.parent(context) name, item_url = get_view_url(context) if container is None: return ({ 'absolute_url': item_url, 'Title': utils.pretty_title_or_id(context, context), }, ) view = getMultiAdapter((container, request), name='breadcrumbs_view') base = tuple(view.breadcrumbs()) # Some things want to be hidden from the breadcrumbs if IHideFromBreadcrumbs.providedBy(context): return base rootPath = getNavigationRoot(context) itemPath = '/'.join(context.getPhysicalPath()) # don't show default pages in breadcrumbs or pages above the navigation # root if not check_default_page_via_view(context, request) \ and not rootPath.startswith(itemPath): base += ({ 'absolute_url': item_url, 'Title': utils.pretty_title_or_id(context, context), }, ) return base
def isDefaultPage(self, obj, request=None): # Finds out if the given obj is the default page in its parent folder. # Uses the lookup rules of Plone. Lookup happens over a view, for which # in theory a different implementation may exist. if request is None: request = self.REQUEST return check_default_page_via_view(obj, request)
def breadcrumbs(self): context = aq_inner(self.context) catalog = getToolByName(context, 'portal_catalog') query = {} # Check to see if the current page is a folder default view, if so # get breadcrumbs from the parent folder if check_default_page_via_view(context, self.request): currentPath = '/'.join(utils.parent(context).getPhysicalPath()) else: currentPath = '/'.join(context.getPhysicalPath()) query['path'] = {'query': currentPath, 'navtree': 1, 'depth': 0} rawresult = catalog(**query) # Sort items on path length dec_result = [(len(r.getPath()), r) for r in rawresult] dec_result.sort() rootPath = getNavigationRoot(context) # Build result dict result = [] for r_tuple in dec_result: item = r_tuple[1] # Don't include it if it would be above the navigation root itemPath = item.getPath() if rootPath.startswith(itemPath): continue cid, item_url = get_view_url(item) data = { 'Title': utils.pretty_title_or_id(context, item), 'absolute_url': item_url } result.append(data) return result