コード例 #1
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;
 }
コード例 #2
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;
 }
コード例 #3
0
 /** Returns */
 public static Call getListProductsUrl(SearchResult<Product> search, Category category) {
   if (search.getCurrentPage() >= search.getTotalPages() - 1) {
     return null;
   }
   // Convert from 0..N-1 to 1..N
   int nextPage = search.getCurrentPage() + 2;
   String categorySlug = "";
   if (category != null) {
     categorySlug = category.getSlug();
   }
   return routes.Categories.listProducts(categorySlug, nextPage);
 }