Created
June 25, 2019 13:35
-
-
Save kieran23101/5a3672ddb7df844c4d26020437e9be08 to your computer and use it in GitHub Desktop.
A razor script used for CartViper to output the top level categories - this doesnt display categories with subcategories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@using System.Dynamic; | |
@using System.Web.UI.HtmlControls; | |
@using DotNetNuke.Common; | |
@using DotNetNuke.Entities.Users; | |
@using CartViper.Modules.Store.Admin; | |
@using CartViper.Modules.Store.Catalog; | |
@using CartViper.Modules.Store.Extensions; | |
@using CartViper.Modules.Store.WebControls; | |
@using CartViper.Modules.Store.Data; | |
@inherits DotNetNuke.Web.Razor.DotNetNukeWebPage<dynamic> | |
@{ | |
CategoryController categoryController = new CategoryController(); | |
//var cats = categoryController.GetCategories(Dnn.Portal.PortalId); | |
var cats = categoryController.GetCategories(Dnn.Portal.PortalId, false, -1, true, StoreLanguage.LocaleToDisplayInStoreUI(Dnn.Portal.PortalId)) | |
.Where(c => c.HasCurrentUserPermissionToViewCategory && c.Archived == false & c.IsDeleted == false).ToList<CategoryInfo>(); | |
ProductController prod = new ProductController(); | |
StoreInfo store = new StoreInfo(); | |
foreach (var cat in cats) | |
{ | |
var getProducts = prod.GetCategoryProducts(cat.CategoryID, false); | |
if (getProducts.Count() > 0) | |
{ | |
var getFirstProd = getProducts[0]; | |
<div class="col-md-6 mb-3 d-flex"> | |
<div class="card w-100 top-level-category-wrapper"> | |
<div class="row no-gutters"> | |
<div class="col-xl-4"> | |
<div class="card-img d-flex align-items-center justify-content-start"> | |
<img src="@(String.IsNullOrEmpty(cat.CategoryImage) ? Globals.ResolveUrl(getFirstProd.MainImage(true).LargeImageUrl(Dnn.Portal.PortalId).ToString() + "?w=170&h=150") : cat.CategoryImage + "?w=170&h=150")" class="card-img" alt="@cat.CategoryName Thumbnail" /> | |
</div> | |
</div> | |
<div class="col-xl-8 d-flex"> | |
<div class="card-body d-flex flex-column top-level-category-body" aria-categoryid="@cat.CategoryID" aria-categorytitle="@cat.CategoryName" aria-categorydescription="@cat.CategoryDescription"> | |
<h5 class="card-title"><a href="@this.CreateCategoryPagingUrl(cat.CategoryPageId.Value, cat.CategoryID, null)">@cat.CategoryName</a></h5> | |
<p class="card-text category-summary">@(String.IsNullOrEmpty(cat.CategorySummary) ? "We have a number of miscellaneous items available to hire that include trolley jacks, plaster board lifters, snow blowers and battery chargers. " : cat.CategorySummary)</p> | |
<p class="card-text category-counter d-flex justify-content-between"> | |
<small class="text-muted">Product Count: @getProducts.Count</small> | |
<a class="small" href="@this.CreateCategoryPagingUrl(cat.CategoryPageId.Value, cat.CategoryID, null)">View Products</a> | |
</p> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment