plone / plone.app.layout

Core visual components for Plone, such as viewlets and general views
10 stars 30 forks source link

Navigation: Hidden items shown when path partially matches current item #251

Open thomasmassmann opened 3 years ago

thomasmassmann commented 3 years ago

If show excluded items is activated in navigation settings, a hidden content item will show up if the path partially matches the current item.

Example:

path_1 = http://localhost:8080/Plone/nachrichten
path_2 = http://localhost:8080/Plone/nach

path_2 is hidden from navigation, but shows up as soon as path_1 is the current content.

This is because in https://github.com/plone/plone.app.layout/blob/master/plone/app/layout/viewlets/common.py#L334 the compared paths don't have a trailing slash.

Proposed solution: check paths with trailing slash:

- if brain.exclude_from_nav and not context_path.startswith(brain_path):
+ if not context_path.endswith("/"):
+     context_path += "/"
+ brain_path_full = brain_path
+ if not brain_path_full.endswith("/"):
+     brain_path_full += "/"
+ if brain.exclude_from_nav and not context_path.startswith(brain_path_full):

Any thoughts on that?

jensens commented 3 years ago

That is indeed a problem. I like your proposed solution. It would be great if you can prepare a pull request!