IBX DEBUGGING
IBX User NOT ACTIVE
Exception in template (Designs\BS\eCom/Productlist/BS_ProductList.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.cbbabdeccedc.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@using System.ServiceModel.Configuration @using Dynamicweb @using System.Web.Optimization @using System.Web @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @Styles.Render("~/bundles/plugins/styles/bs/bs_productlist") <style> @if (HttpContext.Current.Request.Browser.Type.ToUpper().Contains("INTERNETEXPLORER")) { <text> .thumbnail_wrapper .thumbnail_unwrap .btn-AddToCart-BS { padding-top: 9px; padding-bottom: 5px; } </text> } else if (HttpContext.Current.Request.Browser.Type.ToUpper().Contains(" FIREFOX")) { <text> .thumbnail_wrapper .thumbnail_unwrap .btn-AddToCart-BS { padding-top: 9px; padding-bottom: 5px; } </text> } else { <text> .thumbnail_wrapper .thumbnail_unwrap .btn-AddToCart-BS { padding-top: 7px; padding-bottom: 7px; } </text> } </style> @{ var cartPageID = Base.ChkString(Dynamicweb.Frontend.PageView.Current().Area.Item["CartPageID"]); var ajax_FavoritelistPageID = Base.ChkString(Dynamicweb.Frontend.PageView.Current().Area.Item["Ajax_Favoritelist"]); var ajax_ProductListPaging = Base.ChkString(Dynamicweb.Frontend.PageView.Current().Area.Item["Ajax_ProductListPaging"]); var ajax_ProductListPaging_secondary = Base.ChkString(Dynamicweb.Frontend.PageView.Current().Area.Item["Ajax_ProductListPaging_Secondary"]); } <section class="ProductList_wrapper"> <div class="row"> @{ <div class="responsiveCatalogPadding horizontal"> <div class="row"> <div class="catalog_filterArea"> @using BS_CustomCodes.CustomModules.ProductList.Facets @using Dynamicweb @using Dynamicweb.Backend @using BS_CustomCodes.CustomModules.Product.FrontendHelpers; @using ICSharpCode.SharpZipLib.Zip @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @{ // var searchValue = Base.Request("search"); } <div class="widget margin-top-0"> <div> @Translate("bs_product_count_txt"): <span class="product-count">@GetString("Ecom:ProductList.PageProdCnt")</span> </div> @if (!string.IsNullOrEmpty(searchValue)) { <p> @Translate("bs_search_text"): @searchValue </p> } <ul id="categories"> @foreach (var facetGroup in GetLoop("FacetGroups")) { var facets = facetGroup.GetLoop("Facets"); foreach (var facet in facets) { if (facet.GetInteger("Facet.OptionCount") > 0 && facet.GetInteger("Facet.OptionWithResultCount") > 0) { var facetOptions = facet.GetLoop("FacetOptions"); if (facetOptions.All(x => x.GetString("FacetOption.Label").Contains('|'))) { continue; } <li queryparameter="@facet.GetString("Facet.QueryParameter")"> <a href="javascript:void(0);" class="panelSlideTrigger plus"></a> <a href="#">@facet.GetString("Facet.Name")</a> <a class="bs-remove-active-filters" style="display: none;" href="#">@Translate("bs_remove_active_filters")</a> <ul> @{ var queryParameter = facet.GetString("Facet.QueryParameter"); if (queryParameter != "Alder" && queryParameter != "Utgivelsesår") { facetOptions = facetOptions.OrderByDescending(o => o.GetInteger("FacetOption.Count")).ToList(); } if (queryParameter == "Utgivelsesår") { facetOptions = facetOptions.OrderByDescending(o => o.GetInteger("FacetOption.Label")).ToList(); } } @foreach (var option in facetOptions) { if (option.GetString("FacetOption.Label").Contains('|')) { continue; } else { <li class="filter-option always-hidden" style="display: none;"> <i facetselected="@option.GetString("FacetOption.Selected")" class="fa fa-check-square-o" aria-hidden="true"></i> <i facetselected="@option.GetString("FacetOption.Selected")" class="fa fa-square-o" aria-hidden="true"></i> <a facetselected="@option.GetString("FacetOption.Selected")" facetvalue="@HttpUtility.UrlEncode(option.GetString("FacetOption.Value"))" onclick="" href="#"> @FacetHelper.DetermineLabel(facet.GetString("Facet.QueryParameter"), option.GetString("FacetOption.Label")) <span> (@option.GetString("FacetOption.Count")) </span> </a> </li> } } <a class="bs-product-filters-more" style="display: none;" href="#">@Translate("t_loadMoreoptions")</a> </ul> </li> } } } <li queryparameter="" style="display: none;"> <a href="javascript:void(0);" class="panelSlideTrigger plus"></a> <a href="#">Lager</a> <ul> <li class="filter-option stock-filter always-hidden" style="display: none;"> <i facetselected="False" class="fa fa-check-square-o" aria-hidden="true"></i> <i facetselected="False" class="fa fa-square-o" aria-hidden="true"></i> <a facetselected="False" class="stock-filter-trigger" facetvalue="" onclick="" href="#"> @Translate("bs_productlist_hide_soldout") </a> </li> </ul> </li> <hr /> @{ var groupId = Base.ChkString(Base.Request("GroupID")); var search = Base.ChkString(Base.Request("search")); var facetList = new List<Facet>() { new Facet() { fieldValue = "Author", QueryParameter = "Author", FacetName = "Forfatter", isDynamic = false, facetField = "SavedForfatter"}, new Facet() { fieldValue = "PublishHouseName", QueryParameter = "Forlag", FacetName = "Forlag", isDynamic = false, facetField = "SavedPublishHouseName"}, new Facet() { fieldValue = "Series", QueryParameter = "Serie", FacetName = "Serie", isDynamic = false, facetField = "SavedSeries"}, new Facet() { fieldValue = "151", QueryParameter = "Genre", FacetName = "Emne", isDynamic = true, facetField = "SavedGenre"}, }; } @foreach (var facet in facetList) { /*var options = FacetHelper.GetSearchFacet(facet.fieldValue, facet.QueryParameter, facet.FacetName, groupId, 0d, 15d, search, facet.isDynamic); if (!options.Any()) { continue; }*/ <li class="" queryparameter="@facet.QueryParameter" isdynamic="@facet.isDynamic.ToString()" fieldvalue="@facet.fieldValue" facetname="@facet.FacetName" facetField="@facet.facetField"> <a href="javascript:void(0);" class="panelSlideTrigger plus"></a> <a href="#">@facet.FacetName</a> <i style="display: none;" class="fa fa-spin fa-spinner" aria-hidden="true"></i> <ul> <input style="display: none;" class="facetSearch" type="text" /> @{ /* foreach (var option in options) { <li style="display: none;"> <i facetselected="False" class="fa fa-check-square-o" aria-hidden="true"></i> <i facetselected="False" class="fa fa-square-o" aria-hidden="true"></i> <a facetselected="False" facetvalue="option.Value" onclick="" href="#"> option.Label </a> </li> } */ } </ul> </li> } </ul> <ul id="categories" class="bs-remove-filters"> <li class=""> <div class=""> <a href="javascript:void(0);" class="btn btn-default clearFiltersButton no-border-radius"><i class="fa fa-times"></i>@Translate("bs_remove_filters")</a> <div class="clearfix"></div> </div> </li> </ul> </div> </div> <div class="catalog_sortingArea"> @using System.Drawing.Drawing2D @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @{ //&SortBy=ProductCreated&SortOrder=Asc //&SortBy=Name&SortOrder=Asc //&SortBy=Price&SortOrder=Asc var listviewValue = ""; if (HttpContext.Current.Request.Cookies["listview"] != null) { listviewValue = string.IsNullOrEmpty(HttpContext.Current.Request.Cookies["listview"].Value) ? setCookie() : getCookie(); } else { listviewValue = setCookie(); } } <style> .orderby { display: inline-block; } .direction { display: inline-block; } input.price-range { float: right; padding: 10px 12px 10px 12px; width: 192px; line-height: 18px; background-color: #fff; display: inline-block; margin-top: 9px; margin-right: 5px; } .bs-sorting-options { margin-bottom: 10px; position: relative; } .bs-sorting-options .CatalogViewOptions { position: absolute; top: 0; right: 5px; } .bs-sorting-options .checkbox-div { float: right; position: absolute; top: 0; font-weight: 500; right: 110px; } .bs-sorting-options .checkbox-div label { font-weight: inherit !important; } .sort-options { width: 315px; margin-left: auto; margin-right: auto; } .newest-sort-btn { height: 21px; width: 120px; line-height: 0.5; margin-top: -2px; } @@media only screen and (min-width: 1200px) { .pagination ul { padding-left: 5px; } } @@media only screen and (min-width: 0px) and (max-width: 1200px) { .catalog_sortingArea { width: 100%; padding: 0px 15px 0px 15px; } } @@media only screen and (min-width: 0px) and (max-width: 700px) { .catalog_sortingArea { height: 75px; padding: 5px 15px 0 15px; } .sort-options { margin-left: 15px !important; } .bs-sorting-options .checkbox-div { margin-top: 30px; right: 0; } .pagination-container.top .pagination { margin: 10px 0 0 -9px; } } </style> <form autocomplete="off" class="bs-sorting-options"> <div class="sort-options"> <select class="orderby"> <option sortby="">@Translate("bs_prodcatalog_sort")</option> <option sortby="Sys_ReleaseDateSortFieldExtender">@Translate("bs_prodcatalog_releasedate")</option> <option sortby="SortAuthor">@Translate("bs_prodcatalog_author")</option> <option sortby="SortProductName">@Translate("bs_prodcatalog_title")</option> </select> <select class="direction"> <option sortby="Desc">@Translate("bs_direction_descending")</option> <option sortby="Asc">@Translate("bs_direction_ascencding")</option> </select> <select class="listtype" style="display: none;"> @{ if (listviewValue == "matrix") { <option value="matrix" sortby="matrix">@Translate("bs_sort_portrait")</option> <option value="list" sortby="list">@Translate("bs_sort_list")</option> } else if (listviewValue == "list") { <option value="list" sortby="list">@Translate("bs_sort_list")</option> <option value="matrix" sortby="matrix">@Translate("bs_sort_portrait")</option> } } </select> @* <a href="javascript:void(0)" class="btn btn-default newest-sort-btn">@Translate("bs_sorting_show_newest")</a> *@ </div> <input class="price-range price-max" style="display: none;" placeholder="Max" type="number" autocomplete="off" /> <input class="price-range price-min" style="display: none;" placeholder="Min" type="number" autocomplete="off" /> <div style="" class="checkbox-div"> <input style="display: none;" id="show-upcoming-products" type="checkbox" /> <label style="display: none;" for="show-upcoming-products">@Translate("bs_productlist_show_upcoming")</label> <input id="show-expired-products" type="checkbox" checked="" /> <label for="show-expired-products">@Translate("bs_productlist_hide_soldout")</label> </div> <div class="CatalogViewOptions"> @if (listviewValue == "matrix") { <a href="javascript:void(0);" class="btn btn-default prodCatalog_utility_button no-border-radius"><i class="fa fa-th-list fa-fw"></i></a> <a href="javascript:void(0);" class="btn btn-main_color prodCatalog_utility_button no-border-radius"><i class="fa fa-th-large fa-fw"></i></a> } else if (listviewValue == "list") { <a href="javascript:void(0);" class="btn btn-main_color prodCatalog_utility_button no-border-radius"><i class="fa fa-th-list fa-fw"></i></a> <a href="javascript:void(0);" class="btn btn-default prodCatalog_utility_button no-border-radius"><i class="fa fa-th-large fa-fw"></i></a> } </div> </form> @functions { private string setCookie() { var defaultVal = "matrix"; HttpContext.Current.Response.SetCookie(new HttpCookie("listview") { Value = defaultVal }); return getCookie(); } private string getCookie() { return HttpContext.Current.Request.Cookies["listview"].Value; } } </div> <div class="catalog_zfix catalog_ProductsArea"> <i class="fa fa-spinner fa-spin" aria-hidden="true" style="display: none;"></i> @using Dynamicweb @using Dynamicweb.Modules.UserManagement @using System.Web @using System.Collections.Generic @using Dynamicweb @using Dynamicweb.Modules.UserManagement @using BS.Common @using System.IO @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @{ var ajaxCartPageID = Base.ChkString(Dynamicweb.Frontend.PageView.Current().Area.Item["Ajax_CartPageID"]); var listview = "matrix"; // matrix || list try { if (!string.IsNullOrEmpty(Dynamicweb.Input.Request("listview"))) { listview = Dynamicweb.Input.Request("listview"); HttpContext.Current.Response.Cookies["listview"].Value = listview; } else { if (HttpContext.Current.Request.Cookies["listview"] != null) { listview = HttpContext.Current.Request.Cookies["listview"].Value; } else { HttpContext.Current.Response.Cookies["listview"].Value = listview; } } } catch { HttpContext.Current.Response.Cookies.Add(new HttpCookie("listview", listview)); } } @{ //BINDINGS SQL string sqlQuery = string.Format("SELECT * FROM EGIntBinding"); var bindingList = new Dictionary<string, string>(); try { using (var db = Dynamicweb.Database.CreateDataReader(sqlQuery)) { try { while (db.Read()) { string id = db["bindingId"].ToString(); string name = db["name"].ToString(); bindingList.Add(id, name); } } catch { } } } catch { } //END BINDINGS SQL } <div class="products-container"> @{ if (listview == "matrix") { <text> @using BS.Common.CustomModules.Favorites @using Dynamicweb @using Dynamicweb.Modules.UserManagement @using System.Web @using System.Collections.Generic @using Dynamicweb @using Dynamicweb.Modules.UserManagement @using BS.Common @using System.IO @using BS_CustomCodes.CustomModules.ProductList @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @{ var productList = GetLoop("Products"); int areaID = Pageview.Area.ID; var GlobalSolution_ConfigReader = new GlobalSolution_ConfigReader(); int prod_ajaxCartPageID = GlobalSolution_ConfigReader.getPageID_ByArea("Ajax_CartPageID", string.Format("Area_{0}", areaID.ToString())); var prodkatalog = Base.ChkString(Dynamicweb.Frontend.PageView.Current().Area.Item["ProdCatalog"]); var thisUser = Dynamicweb.Modules.UserManagement.User.get_Current(PagePermissionLevels.Frontend); FavoritesHandler favoritesHandler = null; if (thisUser != null) { favoritesHandler = new FavoritesHandler(Base.ChkString(thisUser.ID)); } // Get prices in one call var productModelList = new List<GetPriceProductModel>(); foreach (var productItem in GetLoop("Products")) { productModelList.Add(new GetPriceProductModel() { Id = productItem.GetString("Ecom:Product.ID"), Bindings = productItem.GetString("Ecom:Product:Field.Bindings.Value.Clean") }); } var bindingPrices = ProductListBindingPrice.GetBindingPrices(productModelList); } @helper GetImageScaledById_Portrait(string id, int height, string itemrel) { //Image string path = "/Files/ProductImages/"; string filepath = String.Format("~{0}", path); var serverpath = System.Web.HttpContext.Current.Server.MapPath(filepath); try { var file = System.IO.Directory.GetFiles(serverpath, String.Format("{0}.*", id)).First(); var filename = Path.GetFileName(file); @String.Format("<img style='height: 180px;' src='/admin/public/getimage.ashx?Image={0}{1}&height={2}' itemrel='{3}' class='mainIng'/>", path, filename, height, itemrel); } catch { string noimage = Dynamicweb.Frontend.PageView.Current().Area.Item["DefaultImage"].ToString(); @String.Format("<img style='height: 180px;' src='/admin/public/getimage.ashx?Image={0}&height={1}' itemrel='{2}' class='mainIng'/>", noimage, height, itemrel); } } @foreach (var i in productList) { var canBeBought = Base.ChkBoolean(i.GetString("Product.Ecom.CanBeBought")); //CanBeBoughtProductTemplateExtender var prodID = i.GetString("Ecom:Product.ID"); var prodName = i.GetString("Ecom:Product.Name"); var seriesNr = i.GetString("Ecom:Product:Field.SeriesNumber.Value.Clean"); if (!string.IsNullOrEmpty(seriesNr)) { if (prodName.Length > 22) { prodName = string.Format("{0}... ({1})", prodName.Substring(0, 22), seriesNr); } } else { if (prodName.Length > 28) { prodName = string.Format("{0}...", prodName.Substring(0, 25)); } } var linkToProduct = i.GetString("Ecom.Product.DirectLink"); //GetString("Ecom:Product.LinkGroup.Clean"); var authorLink = String.Format("{0}&Author=%22{1}%22", prodkatalog, i.GetString("Ecom:Product:Field.Author.Value.Clean")); string author = i.GetString("Ecom:Product:Field.Author.Value.Clean"); author = author.Length == 0 ? "" : author; string currency_code = i.GetString("Ecom:Product.Price.Currency.Code"); string pricePrice = i.GetString("Ecom:Product.Price.Price"); var itemNumber = i.GetString("Ecom:Product.Number"); var publishedDate = i.GetString("Ecom:Product:Field.PublishedDate.Value.Clean"); if (publishedDate == "01-01-1900" || publishedDate == "01-01-1990") { publishedDate = ""; } DateTime date = new DateTime(); DateTime minDate = new DateTime(); if (publishedDate.Length > 0) { try { date = DateTime.ParseExact(publishedDate, "dd-mm-yyyy", System.Globalization.CultureInfo.InvariantCulture); minDate = DateTime.ParseExact("01-01-1900", "dd-mm-yyyy", System.Globalization.CultureInfo.InvariantCulture); } catch (Exception e) { } } publishedDate = publishedDate == "" ? i.GetString("Ecom:Product:Field.StatusDate.Value.Clean") : publishedDate; publishedDate = publishedDate.Replace("-", "."); var colorCode = i.GetString("Ecom:Product:Field.StatusColor.Value.Clean"); var statusColor = colorCode == "0" ? "color: rgb(124,183,51)" : ""; // Grøn statusColor = colorCode == "2" ? "color: #ff0000" : statusColor; // Rød statusColor = colorCode == "1" ? "color: #ffa500" : statusColor; // Orange publishedDate = string.IsNullOrEmpty(publishedDate) ? i.GetString("Ecom:Product:Field.PublishYear.Value.Clean") : publishedDate; var coverType = i.GetString("Ecom:Product:Field.CoverType.Value.Clean"); var language = i.GetString("Ecom:Product:Field.Language.Value.Clean"); var publishBindingId = i.GetString("Ecom:Product:Field.PublishBindingId.Value.Clean"); bool grantAccess = false; grantAccess = (GetGlobalValue("Global:Page.IsCurrentUserAllowed") == "True") ? true : false; // Price var baseprice = i.GetValue("Ecom:Product.Price"); var PriceWithBinding = ""; try { PriceWithBinding = bindingPrices[prodID]; } catch { } var bindingprice_list = PriceWithBinding.Split(';'); var productBindingString = i.GetString("Ecom:Product:Field.Bindings"); var binding = productBindingString.Split(',').FirstOrDefault(); var dict = new Dictionary<string, string>(); foreach (var bindingprice in bindingprice_list) { try { var splitprice = bindingprice.Split(':'); var type = splitprice[0]; var amount = splitprice[1]; dict.Add(type, amount); } catch (Exception e) { } } <div style="height: 396px; margin-bottom: 10px; border-bottom:1px solid #EEE;" class="thumbnail_wrapper" itemrel="@prodID"> <div class="thumbnail" style="visibility: hidden;"> <a href="@linkToProduct"> @{ var id = i.GetString("Ecom:Product.Number"); var isCulture = i.GetBoolean("Ecom.Product.IsKulturFond"); // Comes from IsKulturfondProductTemplateExtender var isDigital = i.GetBoolean("Ecom:Product:Field.Digital.Value.Clean"); } <div class="row image-box-row"> @if (isCulture && isDigital) { <div class="image-box"> <div class="ribbon isCultureAndDigital"> <span> @Translate("bs_kulturfond_and_digital_ribbon", "Kulturfond / Digital") </span> </div> @GetImageScaledById_Portrait(id, 240, prodID) </div> } else if (isCulture) { <div class="image-box"> <div class="ribbon isCulture"> <span> @Translate("bs_kulturfond_ribbon", "Kulturfond") </span> </div> @GetImageScaledById_Portrait(id, 240, prodID) </div> } else if (isDigital) { <div class="image-box"> <div class="ribbon isDigital"> <span> @Translate("bs_digital_ribbon", "Digital") </span> </div> @GetImageScaledById_Portrait(id, 240, prodID) </div> } else { <div class="image-box"> @GetImageScaledById_Portrait(id, 240, prodID) </div> } </div> <!-- <img src="@@imgSrc" alt="" class="mainIng" itemrel="@prodID" /> --> </a> <div class="caption"> <h4 style="margin-bottom:5px !important;"> <a href="@linkToProduct">@prodName</a> </h4> @if (colorCode == "2") { <div class="thumbnail_field_publisheddate pubD_red" style="@statusColor">@publishedDate</div> } else if (colorCode == "1") { <div class="col-md-12 col-xs-12 thumbnail_field_publisheddate" style="@statusColor">@publishedDate</div> } else if (colorCode == "0") { <div class="col-md-12 col-xs-12 thumbnail_field_publisheddate" style="@statusColor">@publishedDate</div> } <p> <span class="span_author"> @author </span> </p> @{ if (grantAccess) { try { if (bindingprice_list.Length > 0) { <p><span class="Span_Price" type="@binding">@dict[binding] @currency_code</span></p> } else { <p><span class="Span_Price">@pricePrice @currency_code</span></p> } } catch (Exception e) { <p><span class="Span_Price">@pricePrice @currency_code</span></p> } } else { <p><span class="Span_Price">@pricePrice @currency_code</span></p> } } </div> </div><!-- /thumbnail--> <div class="thumbnail_unwrap" style="display: block; height: 395px;"> <a href="@linkToProduct"> <div class="row image-box-row" style="height: 180px;"> @if (isCulture && isDigital) { <div class="image-box"> <div class="ribbon isCultureAndDigital"> <span> @Translate("bs_kulturfond_and_digital_ribbon", "Kulturfond / Digital") </span> </div> @GetImageScaledById_Portrait(id, 240, prodID) </div> } else if (isCulture) { <div class="image-box"> <div class="ribbon isCulture"> <span style=""> @Translate("bs_kulturfond_ribbon", "Kulturfond") </span> </div> @GetImageScaledById_Portrait(id, 240, prodID) </div> } else if (isDigital) { <div class="image-box"> <div class="ribbon isDigital"> <span style=""> @Translate("bs_digital_ribbon", "Digital") </span> </div> @GetImageScaledById_Portrait(id, 240, prodID) </div> } else { <div class="image-box"> @GetImageScaledById_Portrait(id, 240, prodID) </div> } </div> <!-- <img src="@@imgSrc" alt="" class="mainIng" itemrel="@prodID" /> --> </a> <div class="caption_hover"> <h4 style="min-height:inherit !important; height:inherit !important; font-size:14px; margin-bottom:5px !important;"> <a href="@linkToProduct">@prodName</a> </h4> <div style="height: 20px;" class="bs_prod_hover_author"><a href="@authorLink">@author</a></div> <div class="thumbnail_fields row"> @{ var message = i.GetString("Ecom.Product.StatusColor.Message"); var status = i.GetString("Ecom.Product.StatusColor.Status"); if (status == "Soldout") { <div class="col-md-12 col-xs-12 thumbnail_field_publisheddate text-red" style="@statusColor">@publishedDate</div> } else if (status == "TempSoldout") { <div class="col-md-12 col-xs-12 thumbnail_field_publisheddate" style="@statusColor">@publishedDate</div> } else if (status == "InSale") { <div class="col-md-12 col-xs-12 thumbnail_field_publisheddate" style="@statusColor">@publishedDate</div> } else { <div class="thumbnail_field_publishBindingId_empty_line"></div> } } @if (itemNumber.Length > 0) { <div class="col-md-12 col-xs-12 thumbnail_field_number">@itemNumber</div> } else { <div class="thumbnail_field_publishBindingId_empty_line"></div> } @if (coverType.Length > 0) { <div class="col-md-12 col-xs-12 thumbnail_field_covertype">@coverType</div> } @if (publishBindingId.Length > 0 || language.Length > 0) { <div class="col-md-12 col-xs-12 thumbnail_field_publishBindingId">@publishBindingId<text>@((publishBindingId.Length > 0 && language.Length > 0) ? ", " : string.Empty)</text>@language</div> } else { <div class="thumbnail_field_publishBindingId_empty_line"></div> } @*if (language.Length > 0) { <div class="col-md-12 col-xs-12 thumbnail_field_language">@language</div> }*@ </div> <div class="thumbnail_PriceDiv" style="height:35px !important;"> @{ if (grantAccess) { // Price try { if (bindingprice_list.Length > 0) { var savedBinding = dict[binding]; <h4 style="margin-bottom: 0px;" type="@binding">@savedBinding @currency_code</h4> <div style="display: none; clear: both;"></div> } else { <h4 style="margin-bottom:10px; margin-top:10px;">@pricePrice @currency_code</h4> <div style="display:none;clear:both;"></div> } } catch (Exception e) { <h4 style="margin-bottom:10px; margin-top:10px;">@pricePrice @currency_code</h4> <div style="display:none;clear:both;"></div> } } else { <h4 style="margin-bottom:0px;">@pricePrice @currency_code</h4> <div style="display:none;clear:both;"></div> } } </div> <div> </div> <div> @{ int prodExistsInFavoriteLists = FavoriteList.prod_belongsToList(thisUser.ID.ToString(), prodID); var userFavoritted = favoritesHandler.UserFavorittedProduct(prodID); var centerAlignWishButton = ""; var left = "left: 16px;"; if (!canBeBought) { centerAlignWishButton = "centerAlignWishButton"; left = "left: 6px;"; } else if (prodExistsInFavoriteLists > 0 || userFavoritted) { left = "left: 7px;"; } } <div style="display: inline-block; width: 200px; position: relative; height: 34px;"> <div class="@centerAlignWishButton" style="position: absolute; @left right: auto; top: 0; bottom: 0; width: 192px;"> @{ if (grantAccess) { if (prodExistsInFavoriteLists > 0 || userFavoritted) { <a itemrel="@prodID" style="float: left; margin-right: 3px;" class="btn btn-default favoriteProductListTrigger" id="" data-toggle="modal">@Translate("Legg i huskeliste") <i class="fa fa-check"></i></a> } else { <a itemrel="@prodID" style="float: left; margin-right: 3px;" class="btn btn-default favoriteProductListTrigger" id="" data-toggle="modal">@Translate("Legg i huskeliste")</a> } } else { <a onclick="showLoginModal()" style="float: left; margin-right: 3px;" class="btn btn-default" id="">@Translate("Legg i huskeliste")</a> } } @{ if (canBeBought) { <input type="text" value="1" style="width: 30px; height: 34px; display: inline; text-indent: 10px; padding: 0;" name="quantity" class="form-control Quantity qty_to_add no-border-radius" itemrel="@prodID" /> <a href="#" style="display: inline;" ajaxcartpageid="@prod_ajaxCartPageID" prodid="@prodID" mediachoice="@i.GetString("Ecom.Product.MediaChoice")" subscription="@i.GetString("Ecom.Product.UserHasSubscription")" class="btn btn-red btn-AddToCart-BS fullwidthbtn no-border-radius"> <div style="display: inline;">@Translate("Kjøp")</div> </a> } } </div> </div> </div> </div> </div> </div> } </text> } else { <text> @using System.Collections.Generic @using BS.Common.CustomModules.Favorites @using Dynamicweb @using Dynamicweb.Modules.UserManagement @using BS.Common @using System.IO @using BS_CustomCodes.CustomModules.ProductList @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @{ int areaID = Pageview.Area.ID; var GlobalSolution_ConfigReader = new GlobalSolution_ConfigReader(); int prod_ajaxCartPageID = GlobalSolution_ConfigReader.getPageID_ByArea("Ajax_CartPageID", string.Format("Area_{0}", areaID.ToString())); string PageID = GetGlobalValue("Global:Page.ID"); var prodkatalog = Base.ChkString(Dynamicweb.Frontend.PageView.Current().Area.Item["ProdCatalog"]); bool grantAccess = false; grantAccess = (GetGlobalValue("Global:Page.IsCurrentUserAllowed") == "True") ? true : false; var thisUser = Dynamicweb.Modules.UserManagement.User.get_Current(PagePermissionLevels.Frontend); FavoritesHandler favoritesHandler = null; if (thisUser != null) { favoritesHandler = new FavoritesHandler(Base.ChkString(thisUser.ID)); } // Get prices in one call var productModelList = new List<GetPriceProductModel>(); foreach (var productItem in GetLoop("Products")) { productModelList.Add(new GetPriceProductModel() { Id = productItem.GetString("Ecom:Product.ID"), Bindings = productItem.GetString("Ecom:Product:Field.Bindings.Value.Clean") }); } var bindingPrices = ProductListBindingPrice.GetBindingPrices(productModelList); } @helper GetImageScaledById_List(string id, int height) { //Image string path = "/Files/ProductImages/"; string filepath = String.Format("~{0}", path); var serverpath = System.Web.HttpContext.Current.Server.MapPath(filepath); try { var file = System.IO.Directory.GetFiles(serverpath, String.Format("{0}.*", id)).First(); var filename = Path.GetFileName(file); @String.Format("<img src='/admin/public/getimage.ashx?Image={0}{1}&height={2}' class=''/>", path, filename, height); } catch { string noimage = Dynamicweb.Frontend.PageView.Current().Area.Item["DefaultImage"].ToString(); @String.Format("<img src='/admin/public/getimage.ashx?Image={0}&height={1}' class=''/>", noimage, height); } } <input type="hidden" value="True" id="OptimiseProductCatalogWidth" /> <div class="ProductList"> @{ foreach (LoopItem i in GetLoop("Products")) { var loopMod2 = i.GetValue("Products.LoopMod4"); var prodID = i.GetString("Ecom:Product.ID"); var prodNr = i.GetString("Ecom:Product.Number"); var prodName = i.GetString("Ecom:Product.Name"); var linkToProduct = i.GetString("Ecom.Product.DirectLink"); //GetString("Ecom:Product.LinkGroup.Clean"); var authorLink = String.Format("{0}&Author=%22{1}%22", prodkatalog, i.GetString("Ecom:Product:Field.Author.Value.Clean")); var price = i.GetString("Ecom:Product.Price.PriceWithVAT"); var currencyCode = i.GetString("Ecom:Product.Price.Currency.Code"); var canBeBought = Base.ChkBoolean(i.GetString("Product.Ecom.CanBeBought")); //CanBeBoughtProductTemplateExtender string author = i.GetString("Ecom:Product:Field.Author.Value.Clean"); var review = i.GetString("Ecom:Product:Field.Review.Value.Clean"); var publishedDate = i.GetString("Ecom:Product:Field.PublishedDate.Value.Clean"); if (publishedDate == "01-01-1900" || publishedDate == "01-01-1990") { publishedDate = ""; } DateTime date = new DateTime(); DateTime minDate = new DateTime(); if (publishedDate.Length > 0) { try { date = DateTime.ParseExact(publishedDate, "dd-mm-yyyy", System.Globalization.CultureInfo.InvariantCulture); minDate = DateTime.ParseExact("01-01-1900", "dd-mm-yyyy", System.Globalization.CultureInfo.InvariantCulture); } catch (Exception e) { } } if (publishedDate.Length == 0 && minDate >= date) { publishedDate = ""; } publishedDate = publishedDate == "" ? i.GetString("Ecom:Product:Field.StatusDate.Value.Clean") : publishedDate; publishedDate = publishedDate.Replace("-", "."); var colorCode = i.GetString("Ecom:Product:Field.StatusColor.Value.Clean"); var statusColor = colorCode == "0" ? "color: rgb(124,183,51)" : ""; // Grøn statusColor = colorCode == "2" ? "color: #ff0000" : statusColor; // Rød statusColor = colorCode == "1" ? "color: #ffa500" : statusColor; // Orange var statusText = i.GetString("Ecom:Product:Field.StatusText.Value.Clean"); publishedDate = string.IsNullOrEmpty(publishedDate) ? i.GetString("Ecom:Product:Field.PublishYear.Value.Clean") : publishedDate; var coverType = i.GetString("Ecom:Product:Field.CoverType"); var binding = i.GetString("Ecom:Product:Field.PublishBindingId"); var bindings = i.GetString("Ecom.Product.AvailableBindingsNames"); var remarks = i.GetString("Ecom:Product:Field.ItemNote"); var ean = i.GetString("Ecom:Product:Field.ItemBarcode"); var isCulture = i.GetBoolean("Ecom.Product.IsKulturFond"); // Comes from IsKulturfondProductTemplateExtender var isDigital = i.GetBoolean("Ecom:Product:Field.Digital.Value.Clean"); string t_buy = Translate("Kjøp"); <div class="prod_ListWrapper"> <table class="prod_ListWrapper_table"> <tr> <td valign="top" class="td_ImgHolder"> <div class="prod_List_ImgHolder"> <a href="@linkToProduct"> <div class="row image-box-row"> @if (isCulture && isDigital) { <div class="image-box"> <div class="ribbon isCultureAndDigital"> <span> @Translate("bs_kulturfond_and_digital_ribbon", "Kulturfond / Digital") </span> </div> @GetImageScaledById_List(prodNr, 280) </div> } else if (isCulture) { <div class="image-box"> <div class="ribbon isCulture"><span>@Translate("bs_kulturfond_ribbon", "Kulturfond")</span></div> @GetImageScaledById_List(prodNr, 280) </div> } else if (isDigital) { <div class="image-box"> <div class="ribbon isDigital"><span>@Translate("bs_digital_ribbon", "Digital")</span></div> @GetImageScaledById_List(prodNr, 280) </div> } else { <div class="image-box"> @GetImageScaledById_List(prodNr, 280) </div> } </div> </a> </div> </td> <td valign="top"> <div class="prod_List_InfoHolder"> <div class="prod_List_Header"> @{ var seriesNr = i.GetString("Ecom:Product:Field.SeriesNumber.Value.Clean"); if (!string.IsNullOrEmpty(seriesNr)) { prodName = string.Format("{0} ({1})", prodName, seriesNr); } } <a href="@linkToProduct">@prodName</a> </div> <div class="prod_List_author"> <a href="@authorLink">@author</a> </div> <div class="prod_List_description"> <p>@review</p> </div> <div class="prod_List_details"> @{ var shown_binding = binding; try { var _bindinglist = bindings.Split(';').Select(b => b.Trim()).ToArray(); shown_binding = _bindinglist[0].Split(':').Select(c => c.Trim()).LastOrDefault(); } catch (Exception e) { } } @{ var _isbn = prodNr.Length > 0 ? String.Format("ISBN: {0} ", prodNr) : ""; var publishedDateColored = string.Format("<span style='{1}'>{0} ({2})</span>", publishedDate, statusColor, statusText); var _published = publishedDate.Length > 0 ? String.Format("| {0}: {1} ", Translate("bs_productlist_released", "Ugitt"), publishedDateColored) : ""; var _coverType = coverType.Length > 0 ? String.Format("| {0}", coverType) : ""; var _binding = binding.Length > 0 ? String.Format("| {0}", binding) : ""; var _remarks = remarks.Length > 0 ? String.Format("| {0}", remarks) : ""; var _ean = ean.Length > 0 ? String.Format("| EAN: {0}", ean) : ""; var info = String.Format("{0}{1}{2}{3}{4}{5}", _isbn, _published, _coverType, _binding, _remarks, _ean); } @info </div> <div class="prod_List_Price"> <form action="Default.aspx" method="get" class="formulaDiv" itemrel="@prodID"> @{ // Price var PriceWithBinding = ""; try { PriceWithBinding = bindingPrices[prodID]; } catch { } var bindingprice_list = PriceWithBinding.Split(';'); if (grantAccess) { try { if (bindingprice_list.Length > 0) { var productBindingString = i.GetString("Ecom:Product:Field.Bindings"); var defaultBinding = productBindingString.Split(',').FirstOrDefault(); var dict = new Dictionary<string, string>(); foreach (var bindingprice in bindingprice_list) { var splitprice = bindingprice.Split(':'); var type = splitprice[0]; var amount = splitprice[1]; dict.Add(type, amount); } <span class="prod_List_Price_span" type="@defaultBinding">@dict[defaultBinding] @currencyCode</span> } else { <span class="prod_List_Price_span">@price @currencyCode</span> } } catch (Exception e) { <span class="prod_List_Price_span">@price @currencyCode</span> } } else { <span class="prod_List_Price_span">@price @currencyCode</span> } } <input type="hidden" name="ID" value="@PageID" /> <input type="hidden" name="productid" value="@prodID" /> <input type="hidden" name="cartcmd" value="add" /> @{//Check if user or product is digital. removes buy button if shouldnt be able to buy if (canBeBought) { <div class="prod_List_addToCart_div no-border-radius"> <a href="#" class="btn btn-default no-border-radius btn_qty_add" itemrel="@prodID">+</a> <a href="#" class="btn btn-default no-border-radius btn_qty_sub" itemrel="@prodID">-</a> <input type="text" value="1" name="quantity" class="form-control Quantity qty_to_add no-border-radius" itemrel="@prodID" /> </div> <div class="prod_List_BtnAddToCart_div"> <input type="submit" value="@t_buy" class="btn btn-main_color no-border-radius" itemrel="@prodID" style="display:none;"> <a href="#" ajaxcartpageid="@prod_ajaxCartPageID" prodid="@prodID" mediachoice="@i.GetString("Ecom.Product.MediaChoice")" subscription="@i.GetString("Ecom.Product.UserHasSubscription")" class="btn btn-main_color no-border-radius btn-AddToCart-BS fullwidthbtn">@t_buy</a> </div> } } <div class="addToWishlist_div"> @{ if (grantAccess) { int prodExistsInFavoriteLists = FavoriteList.prod_belongsToList(thisUser.ID.ToString(), prodID); var userFavoritted = favoritesHandler.UserFavorittedProduct(prodID); if (prodExistsInFavoriteLists > 0 || userFavoritted) { <a href="#" itemrel="@prodID" class="btn btn-default favoriteProductListTrigger" id="" data-toggle="modal">@Translate("Legg i huskeliste") <i class="fa fa-check"></i></a> } else { <a href="#" itemrel="@prodID" class="btn btn-default favoriteProductListTrigger" id="" data-toggle="modal">@Translate("Legg i huskeliste")</a> } } else { <a href="#" class="btn btn-default" onclick="showLoginModal()" id="">@Translate("Legg i huskeliste")</a> } } </div> </form> </div> </div> <div style="clear:both;display:none;"></div> </td> </tr> </table> <div class="productListSeparatorFix"> <div class="productListSeparatorFix_border"></div> </div> </div> } } <div style="clear:both;display:none;"></div> </div> </text> } <div style="clear:both;"> </div> } </div> @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @{ } <div class="clearfix"></div> <div class="pagination-container top"> <nav class="pagination" currentpage="@GetString("Ecom:ProductList.CurrentPage")" pageprodcnt="@GetString("Ecom:ProductList.PageProdCnt")" totalpages="@GetString("Ecom:ProductList.TotalPages")"> <ul> @{ var paginationSpan = 3; var currentPage = GetInteger("Ecom:ProductList.CurrentPage"); //var totalPages = GetInteger("Ecom:ProductList.TotalPages"); var pagesToShow = new List<PageItem>(); foreach (var page in GetLoop("Ecom:ProductList.Pages")) { var number = page.GetInteger("Ecom:ProductList.Pages.Page.Number"); if ((page.GetBoolean("Ecom:ProductList.Pages.Page.IsFirstPage") || page.GetBoolean("Ecom:ProductList.Pages.Page.IsLastPage")) || (number - currentPage < paginationSpan && number - currentPage > -paginationSpan)) { pagesToShow.Add(new PageItem() { Number = number, Url = page.GetString("Ecom:ProductList.Pages.Page.Url"), IsCurrent = page.GetBoolean("Ecom:ProductList.Pages.Page.IsCurrent") }); } } var index = 1; } @foreach (var page in pagesToShow) { var current = page.IsCurrent ? "current-page" : ""; if (index == pagesToShow.Count && page.Number - currentPage > paginationSpan) { <li class="dots"> ... </li> } <li class="@current"> <a href="@page.Url" class="">@page.Number</a> </li> if (index == 1 && currentPage > paginationSpan) { <li class="dots"> ... </li> } index++; } </ul> </nav> <nav style="display: none;" class="pagination-next-prev"> <ul> <li><a href="@GetString("Ecom:ProductList.PrevPage.Clean")" class="prev">Next</a></li> <li><a href="@GetString("Ecom:ProductList.NextPage.Clean")" class="next">Prev</a></li> </ul> </nav> </div> @functions { private class PageItem { public int Number; public string Url; public bool IsCurrent; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @{ } <div class="clearfix"></div> <div class="pagination-container bottom"> <nav class="pagination" currentpage="@GetString("Ecom:ProductList.CurrentPage")" pageprodcnt="@GetString("Ecom:ProductList.PageProdCnt")" totalpages="@GetString("Ecom:ProductList.TotalPages")"> <ul> @{ var bottomPaginationSpan = 3; var bottomCurrentPage = GetInteger("Ecom:ProductList.CurrentPage"); //var totalPages = GetInteger("Ecom:ProductList.TotalPages"); var bottomPagesToShow = new List<BottomPageItem>(); foreach (var page in GetLoop("Ecom:ProductList.Pages")) { var number = page.GetInteger("Ecom:ProductList.Pages.Page.Number"); if ((page.GetBoolean("Ecom:ProductList.Pages.Page.IsFirstPage") || page.GetBoolean("Ecom:ProductList.Pages.Page.IsLastPage")) || (number - bottomCurrentPage < bottomPaginationSpan && number - bottomCurrentPage > -bottomPaginationSpan)) { bottomPagesToShow.Add(new BottomPageItem() { Number = number, Url = page.GetString("Ecom:ProductList.Pages.Page.Url"), IsCurrent = page.GetBoolean("Ecom:ProductList.Pages.Page.IsCurrent") }); } } var bottomIndex = 1; } @foreach (var page in bottomPagesToShow) { var bottomCurrent = page.IsCurrent ? "current-page" : ""; if (bottomIndex == bottomPagesToShow.Count && page.Number - bottomCurrentPage > bottomPaginationSpan) { <li class="dots"> ... </li> } <li class="@bottomCurrent"> <a href="@page.Url" class="">@page.Number</a> </li> if (bottomIndex == 1 && bottomCurrentPage > bottomPaginationSpan) { <li class="dots"> ... </li> } bottomIndex++; } </ul> </nav> <nav style="display: none;" class="pagination-next-prev"> <ul> <li><a href="@GetString("Ecom:ProductList.PrevPage.Clean")" class="prev">Next</a></li> <li><a href="@GetString("Ecom:ProductList.NextPage.Clean")" class="next">Prev</a></li> </ul> </nav> </div> @functions { private class BottomPageItem { public int Number; public string Url; public bool IsCurrent; } } </div> <div style="clear:both;display:none;"></div> </div> </div> <div style="clear:both;display:none;"></div> } </div> </section> @Scripts.Render("~/bundles/plugins/scripts/logic/BS_ProductList") @using System.Text.RegularExpressions @using System.Web.Optimization @using Dynamicweb @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @{ } <div class="modal fade" id="bs_productFavoriteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id="productFavoriteModalLabel" data-bind="text: managedProductName">Modal title</h4> </div> <div class="alert alert-success" role="alert" data-bind="visible: success()"> <button type="button" class="close" data-bind="click: success(false)"><span aria-hidden="true">&times;</span></button> <div> <div data-bind="text: successString()"></div> </div> </div> <div class="alert alert-danger" role="alert" data-bind="visible: error()"> <button type="button" data-bind="click: error(false)" class="close"><span aria-hidden="true">&times;</span></button> <strong>@Translate("bs_katalog_favorite_error")</strong> </div> <div class="modal-body" > <div data-bind="foreach: favoritesList"> <label style="display: block;" data-bind="if: $parent.favoritesList().length > 0"> <input onclick="addOrRemoveToFavoriteList(this)" type="checkbox" data-bind="attr: { 'checked': ListProductIDs.indexOf($parent.managedProductId()) > -1 }" /> <span data-bind="text: ListName"></span> </label> <hr /> </div> <div class="input-group"> <input type="text" class="form-control" placeholder="@Translate("bs_new_wishlist_placeholder")" /> <span class="input-group-btn"> <button class="btn btn-primary" onclick="createAndAddToFavoriteList(this)" type="button"> @Translate("BS_New_Favorite") </button> </span> </div> </div> <div class="modal-footer"> <a type="button" class="btn btn-default button" data-dismiss="modal">@Translate("BS_Close")</a> </div> </div> </div> </div> <script type="text/javascript"> var favoritesPageId = "@Regex.Match(Base.ChkString(Dynamicweb.Frontend.PageView.Current().Area.Item["Ajax_Favoritelist"]), @"\d+").Value"; var favorites_successAdd = '@Translate("bs_katalog_favorite_add")'; var favorites_successRemove = '@Translate("bs_katalog_favorite_remove")'; var wishRemove = '@Translate("Fjern")'; var wishAdd = '@Translate("Legg i huskeliste")'; </script> @Scripts.Render("~/bundles/plugins/scripts/logic/BS_FavoriteModal") <script> var groupid = "@GetString("Ecom:Group.ID")"; var searchParameter = "@Base.Request("search")"; var favoritesPageId = parseInt("@ajax_FavoritelistPageID".replace(/[^\d]/g, '')); var cartPageId = "@cartPageID"; var productPagingId = "@ajax_ProductListPaging"; var productPagingId_secondary = "@ajax_ProductListPaging_secondary"; </script>