diff --git a/README.rst b/README.rst index 993a980..daedebe 100644 --- a/README.rst +++ b/README.rst @@ -51,7 +51,7 @@ Supported django CMS versions: you have issues with tags, upgrade to latest version to have it fixed. .. warning:: When upgrading to version 0.6, check that every post as an attached - category, or select a menu without categories. + category, or select a menu without categories. .. warning:: Starting from version 0.5, this package does not declare dependency on South anymore; please install it separately if using this @@ -235,11 +235,14 @@ Menu ``djangocms_blog`` provides support for django CMS menu framework. -By default all the categories and posts are added to the menu, in a hierarcical structure. +By default all the categories and posts are added to the menu, in a hierarchical structure. Is it possibile to configure per Apphook, whether the menu includes post and categories (the default), only categorie, only posts or no item. +If "post and categories" or "only categories" are set, all the posts not associated with a +category are not added to the menu. + Templates +++++++++ @@ -374,14 +377,14 @@ Global Settings (default: ``False``) * BLOG_ADMIN_POST_FIELDSET_FILTER: Callable function to change(add or filter) fields to fieldsets for admin post edit form; (default: ``False``). Function simple example:: - - + + def fieldset_filter_function(fsets, request, obj=None): if request.user.groups.filter(name='Editor').exists(): fsets[1][1]['fields'][0].append('author') # adding 'author' field if user is Editor return fsets - - + + * BLOG_AVAILABLE_PERMALINK_STYLES: Choices of permalinks styles; * BLOG_PERMALINK_URLS: URLConf corresponding to BLOG_AVAILABLE_PERMALINK_STYLES; diff --git a/djangocms_blog/menu.py b/djangocms_blog/menu.py index 036811e..75e5564 100644 --- a/djangocms_blog/menu.py +++ b/djangocms_blog/menu.py @@ -52,20 +52,23 @@ class BlogCategoryMenu(CMSAttachMenu): posts = posts.namespace(self.instance.application_namespace) posts = posts.active_translations(language).distinct() for post in posts: + post_id = None if categories_menu: category = post.categories.first() - parent = '%s-%s' % (category.__class__.__name__, category.pk) - post_id = '%s-%s' % (post.__class__.__name__, post.pk), + if category: + parent = '%s-%s' % (category.__class__.__name__, category.pk) + post_id = '%s-%s' % (post.__class__.__name__, post.pk), else: parent = None post_id = '%s-%s' % (post.__class__.__name__, post.pk), - node = NavigationNode( - post.get_title(), - post.get_absolute_url(language), - post_id, - parent - ) - nodes.append(node) + if post_id: + node = NavigationNode( + post.get_title(), + post.get_absolute_url(language), + post_id, + parent + ) + nodes.append(node) return nodes