Ejemplo n.º 1
0
 /**
  * Compares the categories and returns the 'active' class if are the same.
  *
  * @param category
  * @param currentCategory
  * @return 'active' if categories are the same, otherwise an empty string.
  */
 public static String getActiveClass(Category category, Category currentCategory) {
   String active = "";
   if (currentCategory != null && currentCategory.getPathInTree().contains(category)) {
     active = "active";
   }
   return active;
 }
Ejemplo n.º 2
0
 public static String getCategoryPath(Category category) {
   String path = "";
   int level = category.getPathInTree().size();
   if (level > 1) {
     // Add first 2 oldest ancestors separated by '-'
     List<Category> ancestors = category.getPathInTree().subList(0, level - 1);
     String ancestorsPath = ancestors.get(0).getSlug();
     if (ancestors.size() > 1) {
       ancestorsPath += "-" + ancestors.get(1).getSlug();
     }
     path += ancestorsPath + "/";
   }
   // Add current category
   path += category.getPathInTree().get(level - 1).getSlug();
   return path;
 }