Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reconfigure breadcrumbs view and handle context #516

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion castle/cms/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@

<browser:page
for="*"
name="breadcrumbs_view"
name="castle_breadcrumbs_view"
class=".navigation.PhysicalNavigationBreadcrumbs"
permission="zope2.View"
allowed_attributes="breadcrumbs"
Expand Down
16 changes: 16 additions & 0 deletions castle/cms/browser/navigation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.WorkflowCore import WorkflowException
from Acquisition import aq_inner
from Products.CMFCore.interfaces import IContentish
from Products.CMFPlone import utils
from Products.CMFPlone.browser.interfaces import INavigationBreadcrumbs
from Products.CMFPlone.interfaces import IHideFromBreadcrumbs
Expand All @@ -14,6 +15,21 @@
class PhysicalNavigationBreadcrumbs(BrowserView):

def breadcrumbs(self):
# get actual context object if only site root is passed in as context
site = api.portal.get()
if self.context == site:
context_url = self.request.URL
site_url = site.absolute_url()
path = context_url.replace(site_url, '')
if '/layout_view' in path:
path = path.replace('/layout_view', '')
try:
context = api.content.get(path)
if IContentish.providedBy(context):
self.context = context
except Exception:
return []

context = aq_inner(self.context)

view_utils = Utils(self.context, self.request)
Expand Down
2 changes: 1 addition & 1 deletion castle/cms/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def __call__(self):
['object_buttons', 'object'])

breadcrumbs_view = getMultiAdapter((self.real_context, self.request),
name='breadcrumbs_view')
name='castle_breadcrumbs_view')

user_menu = self.get_menu('user_menu', ['user'])
management_menu = self.get_menu('management_menu')
Expand Down