Fix menu behavior
This commit is contained in:
parent
0f2abd8627
commit
1939ec7919
2 changed files with 21 additions and 15 deletions
|
@ -235,11 +235,14 @@ Menu
|
||||||
|
|
||||||
``djangocms_blog`` provides support for django CMS menu framework.
|
``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
|
Is it possibile to configure per Apphook, whether the menu includes post and categories
|
||||||
(the default), only categorie, only posts or no item.
|
(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
|
Templates
|
||||||
+++++++++
|
+++++++++
|
||||||
|
|
||||||
|
|
|
@ -52,13 +52,16 @@ class BlogCategoryMenu(CMSAttachMenu):
|
||||||
posts = posts.namespace(self.instance.application_namespace)
|
posts = posts.namespace(self.instance.application_namespace)
|
||||||
posts = posts.active_translations(language).distinct()
|
posts = posts.active_translations(language).distinct()
|
||||||
for post in posts:
|
for post in posts:
|
||||||
|
post_id = None
|
||||||
if categories_menu:
|
if categories_menu:
|
||||||
category = post.categories.first()
|
category = post.categories.first()
|
||||||
|
if category:
|
||||||
parent = '%s-%s' % (category.__class__.__name__, category.pk)
|
parent = '%s-%s' % (category.__class__.__name__, category.pk)
|
||||||
post_id = '%s-%s' % (post.__class__.__name__, post.pk),
|
post_id = '%s-%s' % (post.__class__.__name__, post.pk),
|
||||||
else:
|
else:
|
||||||
parent = None
|
parent = None
|
||||||
post_id = '%s-%s' % (post.__class__.__name__, post.pk),
|
post_id = '%s-%s' % (post.__class__.__name__, post.pk),
|
||||||
|
if post_id:
|
||||||
node = NavigationNode(
|
node = NavigationNode(
|
||||||
post.get_title(),
|
post.get_title(),
|
||||||
post.get_absolute_url(language),
|
post.get_absolute_url(language),
|
||||||
|
|
Loading…
Reference in a new issue