django-simple-menu
django-simple-menu copied to clipboard
Feat: option to retain child menu items when visible=False
This PR adds the option for child menu items to not be removed from the list when item.visible == False
.
Usecase
I am using django-simple-menu both for menu items and for breadcrumb generation. There are several cases where a menu item is not visible to click, but can produce an entry in the breadcrumb trail.
As a work-around (and due to the simplicity of the site structure I am working on at present) I have been able to get away with simply leaving visible=True on all items and not rendering any child items. This will not work forever though.
The change
This change adds a new setting MENU_TRIM_NON_VISIBLE_CHILD_ITEMS
which defaults to the existing behaviour of removing all non-visible child items, but, it can be set to False
which will then retain these items. As such, this is a non-breaking change for existing users.
The default templates in this repo should work either way because item.visible
is always checked, but I can appreciate that some people will have custom templates which do not perform this check.
I've added some tests, but please let me know if there's anything further I can do to help get this merged in.