Further navigation highlight improvements
This commit is contained in:
@@ -44,7 +44,8 @@ def register_links(src, links, menu_name=None, position=None):
|
||||
object_navigation[menu_name][src]['links'].extend(links)
|
||||
|
||||
|
||||
def register_top_menu(name, link, children_views=None, children_path_regex=None, position=None):
|
||||
def register_top_menu(name, link, children_views=None, \
|
||||
children_path_regex=None, children_view_regex=None, position=None):
|
||||
"""
|
||||
Register a new menu entry for the main menu displayed at the top
|
||||
of the page
|
||||
@@ -55,6 +56,8 @@ def register_top_menu(name, link, children_views=None, children_path_regex=None,
|
||||
entry['children_views'] = children_views
|
||||
if children_path_regex:
|
||||
entry['children_path_regex'] = children_path_regex
|
||||
if children_view_regex:
|
||||
entry['children_view_regex'] = children_view_regex
|
||||
if position is not None:
|
||||
top_menu_entries.insert(position, entry)
|
||||
else:
|
||||
|
||||
@@ -28,14 +28,16 @@ class TopMenuNavigationNode(Node):
|
||||
menu_links = resolve_links(context, all_menu_links, current_view, current_path)
|
||||
|
||||
for index, link in enumerate(top_menu_entries):
|
||||
children_views = link.get('children_views', [])
|
||||
if current_view in children_views:
|
||||
if current_view in link.get('children_views', []):
|
||||
menu_links[index]['active'] = True
|
||||
|
||||
children_path_regex = link.get('children_path_regex', [])
|
||||
for child_path_regex in children_path_regex:
|
||||
for child_path_regex in link.get('children_path_regex', []):
|
||||
if re.compile(child_path_regex).match(current_path.lstrip('/')):
|
||||
menu_links[index]['active'] = True
|
||||
|
||||
for children_view_regex in link.get('children_view_regex', []):
|
||||
if re.compile(children_view_regex).match(children_view_regex):
|
||||
menu_links[index]['active'] = True
|
||||
|
||||
context['menu_links'] = menu_links
|
||||
return ''
|
||||
|
||||
Reference in New Issue
Block a user