Check variable before accessing attribute

This commit is contained in:
PCoder 2024-06-04 17:07:38 +05:30
parent c5026ad0eb
commit cd99b1bc4f

View file

@ -54,6 +54,7 @@ def top_menu(context, parent, calling_page=None):
menuitems = parent.get_children().live().in_menu().specific() menuitems = parent.get_children().live().in_menu().specific()
for menuitem in menuitems: for menuitem in menuitems:
menuitem.show_dropdown = has_menu_children(menuitem) menuitem.show_dropdown = has_menu_children(menuitem)
if calling_page:
menuitem.active = (calling_page.url.startswith(menuitem.url) menuitem.active = (calling_page.url.startswith(menuitem.url)
if calling_page else False) if calling_page else False)
try: try: