|
@@ -14,14 +14,6 @@ def get_site_root(context):
|
|
|
# attribute 'get_children')
|
|
|
return Site.find_for_request(context["request"]).root_page
|
|
|
|
|
|
-
|
|
|
-def has_menu_children(page):
|
|
|
- # This is used by the top_menu property
|
|
|
- # get_children is a Treebeard API thing
|
|
|
- # https://tabo.pe/projects/django-treebeard/docs/4.0.1/api.html
|
|
|
- return page.get_children().live().in_menu().exists()
|
|
|
-
|
|
|
-
|
|
|
def has_children(page):
|
|
|
# Generically allow index pages to list their children
|
|
|
return page.get_children().live().exists()
|
|
@@ -33,13 +25,10 @@ def is_active(page, current_page):
|
|
|
|
|
|
|
|
|
# Retrieves the top menu items - the immediate children of the parent page
|
|
|
-# The has_menu_children method is necessary because the Foundation menu requires
|
|
|
-# a dropdown class to be applied to a parent
|
|
|
@register.inclusion_tag("tags/top_menu.html", takes_context=True)
|
|
|
def top_menu(context, parent, calling_page=None):
|
|
|
menuitems = parent.get_children().live().in_menu()
|
|
|
for menuitem in menuitems:
|
|
|
- menuitem.show_dropdown = has_menu_children(menuitem)
|
|
|
# We don't directly check if calling_page is None since the template
|
|
|
# engine can pass an empty string to calling_page
|
|
|
# if the variable passed as calling_page does not exist.
|
|
@@ -55,31 +44,6 @@ def top_menu(context, parent, calling_page=None):
|
|
|
"request": context["request"],
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-# Retrieves the children of the top menu items for the drop downs
|
|
|
-@register.inclusion_tag("tags/top_menu_children.html", takes_context=True)
|
|
|
-def top_menu_children(context, parent, calling_page=None):
|
|
|
- menuitems_children = parent.get_children()
|
|
|
- menuitems_children = menuitems_children.live().in_menu()
|
|
|
- for menuitem in menuitems_children:
|
|
|
- menuitem.has_dropdown = has_menu_children(menuitem)
|
|
|
- # We don't directly check if calling_page is None since the template
|
|
|
- # engine can pass an empty string to calling_page
|
|
|
- # if the variable passed as calling_page does not exist.
|
|
|
- menuitem.active = (
|
|
|
- calling_page.url_path.startswith(menuitem.url_path)
|
|
|
- if calling_page
|
|
|
- else False
|
|
|
- )
|
|
|
- menuitem.children = menuitem.get_children().live().in_menu()
|
|
|
- return {
|
|
|
- "parent": parent,
|
|
|
- "menuitems_children": menuitems_children,
|
|
|
- # required by the pageurl tag that we want to use within this template
|
|
|
- "request": context["request"],
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@register.inclusion_tag("tags/breadcrumbs.html", takes_context=True)
|
|
|
def breadcrumbs(context):
|
|
|
self = context.get("self")
|