djangocms-versioning icon indicating copy to clipboard operation
djangocms-versioning copied to clipboard

Bug (or feature?): `CMSMenu.get_nodes()` returns URLs of unpublished pages

Open jrief opened this issue 11 months ago • 2 comments

How to reproduce:

  • Start editing a page which is using a menu renderer.
  • When calling get_nodes from CMSMenu all descendant pages are returned, even those which have never been published.

Expected behaviour:

  • When returning to the published view of a page, only published descendant pages are returned, this behaviour is also expected in edit mode.

The culprit is this line of code. In my opinion states should always be [constants.PUBLISHED], because if someone edits a page, he might be confused to get a different menu structure compared to the published version of that page.

jrief avatar Mar 05 '24 13:03 jrief

This is intentional. This allows navigation to not yet published pages using the menu when editing.

Note: The menu renderer of djangocms-versioning will be deprecated in the next version. It has performance issues. The core's menu renderer has been updated to work universally with and without versioning.

If you only want published pages also in edit mode, I suggest having a look here: https://github.com/django-cms/django-cms/blob/develop-4/cms/cms_menus.py

You can modify the if statement in lines 250ff. The default menus can be replaced, just like djangocms-versioning does replace them.

fsbraun avatar Mar 05 '24 14:03 fsbraun

It might make sense to separate out the if statement (lines 250ff) into a separate method of the CMSMenu class which would allow customization by subclassing.

fsbraun avatar Mar 05 '24 14:03 fsbraun

I close this issue since the cms_menus.py are deprecated.

fsbraun avatar Aug 23 '24 14:08 fsbraun