Merge pull request #195 from nephila/feature/non_required_categories
Fix menu behavior
This commit is contained in:
		
				commit
				
					
						ae2b4a1f6f
					
				
			
		
					 5 changed files with 48 additions and 27 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
                parent = 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
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue