Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
In the Category helper, I have this code:
@using UCommerce.Api @using UCommerce.Extensions @using UCommerce.EntitiesV2 @using UCommerce.Runtime @using umbraco.MacroEngines @helper DisplayCategoryProducts(UCommerce.EntitiesV2.Category category) { var products = CatalogLibrary.GetProducts(category); @uCommerce.Helpers.Product.DisplayListProducts(products, category) foreach (var childCategory in category.Categories) { <div class="row-fluid"> <div class="span12"> <h1>@childCategory.Id @childCategory.DisplayName()</h1> </div>
I would love to use @childCategory.Level so I could make different headline sizes in level 1 and level 2.
Best regardsKim
You can make an extension method to Category that gives you the amount of categories top the top.
on top of my head it would look a little somthing like this:
public static int Level(this Category category) { int level = 0; var currentCategory = category; while (currentCategory.ParentCategory != null) { currentCategory = currentCategory.ParentCategory; level++; } return level; }
Hope that helps
Okay, I will try your code, thanks!
This is a noob question, but how do I use the method inside the helper?
@using UCommerce.Api @using UCommerce.Extensions @using UCommerce.EntitiesV2 @using UCommerce.Runtime @using umbraco.MacroEngines @helper DisplayCategoryProducts(UCommerce.EntitiesV2.Category category) { var products = CatalogLibrary.GetProducts(category); @uCommerce.Helpers.Product.DisplayListProducts(products, category) foreach (var childCategory in category.Categories) { <div class="row-fluid"> <div class="span12"> <h1>Level() @childCategory.DisplayName()</h1> </div> </div> <div class="row-fluid"> @DisplayCategoryProducts(childCategory) </div> } } public static int Level(this Category category) { int level = 0; var currentCategory = category; while (currentCategory.ParentCategory != null) { currentCategory = currentCategory.ParentCategory; level++; } return level; }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Heading on subcategories - Category helper
Hi,
In the Category helper, I have this code:
I would love to use @childCategory.Level so I could make different headline sizes in level 1 and level 2.
Best regards
Kim
You can make an extension method to Category that gives you the amount of categories top the top.
on top of my head it would look a little somthing like this:
Hope that helps
Okay, I will try your code, thanks!
This is a noob question, but how do I use the method inside the helper?
Best regards
Kim
is working on a reply...