Uploaded image for project: 'Magnolia Categorization Module'
  1. Magnolia Categorization Module
  2. MGNLCAT-15

When using hierarchical categories, related categories paragraph should display parent and siblings of category selected in category overview page

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 1.1.3
    • 1.1
    • None
    • Yes

    Description

      Index: src/main/java/info/magnolia/module/categorization/util/CategoryUtil.java
      ===================================================================
      --- src/main/java/info/magnolia/module/categorization/util/CategoryUtil.java	(revision 31605)
      +++ src/main/java/info/magnolia/module/categorization/util/CategoryUtil.java	(working copy)
      @@ -96,7 +96,7 @@
           public static Collection getRelatedCategories(String name) {
               List relatedNodes = new ArrayList();
               try {
      -            Content categoryNode = getCategoryNodeByName(name);
      +            final Content categoryNode = getCategoryNodeByName(name);
                   if(categoryNode.hasContent("relatedUUID")) {
                       Collection uuids = categoryNode.getChildByName("relatedUUID").getChildren();
                       Iterator uuidsIt = uuids.iterator();
      @@ -110,6 +110,23 @@
                           }
                       }
                   }
      +            //Check if has sub categories
      +            if (categoryNode.hasChildren()) {
      +                relatedNodes.addAll(categoryNode.getChildren());
      +            }
      +            // check if has siblings
      +            if(categoryNode.getLevel() > 2) {
      +                Content parent = categoryNode.getParent();
      +                relatedNodes.add(parent);
      +                Iterator childrenIt = parent.getChildren().iterator();
      +
      +                while(childrenIt.hasNext()) {
      +                    Content item = (Content)childrenIt.next();
      +                    if(!categoryNode.getUUID().equals(item.getUUID())) {
      +                        relatedNodes.add(item);
      +                    }
      +                }
      +            }
               } catch (RepositoryException e) {
                   log.warn("cant get category " + name, e);
               }
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              pbaerfuss Philipp Bärfuss
              tmiyar Teresa Miyar
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Task DoD