Hvad leder du efter?

Error executing template "Designs/Rideforbund/QueryPublisher/Events.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_97a35b0713eb421199a93bf0edb7acc6.Execute() in D:\dynamicweb.net\Solutions\Dansk Ride Forbund\Files\Templates\Designs\Rideforbund\QueryPublisher\Events.cshtml:line 655
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb; 3 @using DanskRideForbund.Domain.Constant; 4 @using DanskRideForbund.Translations; 5 6 @using Dynamicweb; 7 @using Dynamicweb.Frontend; 8 @using System.Text.RegularExpressions; 9 10 @functions { 11 string getPageUrl(string url, string parameters = "") 12 { 13 return SearchEngineFriendlyURLs.GetFriendlyUrl(url.TrimStart('/') + (!string.IsNullOrEmpty(parameters) ? (!parameters.StartsWith("&") ? "&" : "") + parameters.Replace(" ", "+") : "")); 14 } 15 16 string getPageUrlById(int id = 0, string parameters = "") 17 { 18 return getPageUrl("Default.aspx?Id=" + (id > 0 ? id : Pageview.Page.ID), parameters); 19 } 20 21 //string getPageUrlByAreaItem(string systemName, string parameters = "", bool useFriendlyUrl = true) 22 //{ 23 // var url = Converter.ToString(Pageview.Area.Item[systemName]); 24 25 // if (string.IsNullOrEmpty(url)) return ""; 26 // else if (useFriendlyUrl) return getPageUrl(url, parameters); 27 // else return "/" + url.TrimStart('/') + (!string.IsNullOrEmpty(parameters) ? (!parameters.StartsWith("&") ? "&" : "") + parameters.Replace(" ", "+") : ""); 28 //} 29 30 string getPageUrlByNavigationTag(string tagName, string parameters = "", bool useFriendlyUrl = true) 31 { 32 var url = "Default.aspx?Id=" + GetPageIdByNavigationTag(tagName); 33 34 if (string.IsNullOrEmpty(url)) return ""; 35 else if (useFriendlyUrl) return getPageUrl(url, parameters); 36 else return "/" + url.TrimStart('/') + (!string.IsNullOrEmpty(parameters) ? (!parameters.StartsWith("&") ? "&" : "") + parameters.Replace(" ", "+") : ""); 37 } 38 39 string getLogoutUrl(bool useRedirect = true) 40 { 41 return "/Admin/Public/extranetlogoff.aspx" + (useRedirect ? "?RedirectUrl=" + Pageview.SearchFriendlyUrl : ""); 42 } 43 44 string getTranslate(string text, string defaultValue) 45 { 46 return Translate(Regex.Replace(text, "[^A-Za-z0-9:.]", ""), defaultValue); 47 } 48 } 49 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 50 @using System.Web; 51 @using Dynamicweb; 52 @using Dynamicweb.Core; 53 @using Dynamicweb.Environment; 54 @using DanskRideForbund.Domain.Core; 55 @using DanskRideForbund.DataSync.Common.Enum; 56 @using DanskRideForbund.BusinessLayer.Provider; 57 @using DanskRideForbund.Translations; 58 59 @functions 60 { 61 const bool useCommaSeparatedParamArrayValues = true; 62 const char queryValueArrayDelimiter = ','; 63 64 bool RequestParamContainsValue(string param, string value) 65 { 66 return Context.Current.Request.HasRequest(param) && (useCommaSeparatedParamArrayValues ? Context.Current.Request.QueryString[param].Split(queryValueArrayDelimiter).Contains(value) : Context.Current.Request.QueryString[param].Contains(value)); 67 } 68 69 string AddOrUpdateUrlParamValue(string absoluteUrl, string param, string newValue) 70 { 71 if (absoluteUrl == null) absoluteUrl = Context.Current.Request.Url.ToString(); 72 Uri uri = new Uri(absoluteUrl); 73 var qParts = HttpUtility.ParseQueryString(uri.Query); 74 qParts[param] = newValue; 75 return uri.AbsolutePath + "?" + qParts.ToString(); //url.AbsolutePath only returns the path portion of the URL(/ mypage.aspx); prepend url.Scheme(http) + Uri.SchemeDelimiter(://) + url.Authority 76 } 77 78 string GetPaginatedLink(int pageNum) 79 { 80 return AddOrUpdateUrlParamValue(null, "pageNum", pageNum.ToString()); 81 } 82 83 string GetTranslator(string method = "", string value = "") 84 { 85 if (!string.IsNullOrEmpty(method) && !string.IsNullOrEmpty(value)) 86 { 87 if (method == "RegionIds" || method == "RegionId") 88 { 89 return Translator.GetRegionDescription(value); 90 } 91 else if (method == "DistrictIds" || method == "DistrictId") 92 { 93 return Translator.GetDistrictDescription(value); 94 } 95 else if (method == "OfficialGroups") 96 { 97 return Translator.GetOfficialGroupDescription(value); 98 } 99 else if (method == "HorseName") 100 { 101 return value; 102 } 103 } 104 105 return Translate("SmartPage:Event." + method + "." + value, value); 106 } 107 } 108 109 @helper renderFacetEndDate(DateTime? startDate = null, DateTime? endDate = null) 110 { 111 startDate = Context.Current.Request.HasRequest("from") ? Context.Current.Request.GetDate("from") : (startDate ?? DateTime.MinValue); 112 endDate = Context.Current.Request.HasRequest("to") ? Context.Current.Request.GetDate("to") : (endDate ?? DateTime.MinValue); 113 114 <div class="form-group"> 115 <label class="label-lg" for="">@Translate("SmartPage:DatePicker.FacetName", "Dato")</label> 116 <div class="row no-gutters align-items-center"> 117 <div class="col"> 118 <div class="input-group input-group-sm"> 119 <div class="input-group-prepend"> 120 <span class="input-group-text"><i class="fas fa-calendar-alt"></i></span> 121 </div> 122 <input type="text" class="form-control form-control-sm js-datepicker js-onchange-submit" name="from" value="@(startDate != DateTime.MinValue ? startDate.Value.ToShortDateString() : "")" placeholder='@Translate("SmartPage:DatePicker.FromDate", "Fra dato")' /> 123 </div> 124 </div> 125 <div class="col-1 text-center">-</div> 126 <div class="col"> 127 <div class="input-group input-group-sm"> 128 <div class="input-group-prepend"> 129 <span class="input-group-text"><i class="fas fa-calendar-alt"></i></span> 130 </div> 131 <input type="text" class="form-control form-control-sm js-datepicker js-onchange-submit" name="to" value="@(endDate != DateTime.MinValue ? endDate.Value.ToShortDateString() : "")" placeholder='@Translate("SmartPage:DatePicker.ToDate", "Til dato")' /> 132 </div> 133 </div> 134 </div> 135 </div> 136 } 137 138 @helper renderFacetGroups(bool showOptionCount = false) 139 { 140 var index = 1; 141 142 foreach (var facetGroup in GetLoop("FacetGroups")) 143 { 144 var facets = facetGroup.GetLoop("Facets"); 145 146 foreach (var facet in facets.Where(i => i.GetString("Facet.RenderType") != "DistrictCheckboxes")) 147 { 148 var showFacetOptionCount = facet.GetString("Facet.Type") == "Term" ? false : showOptionCount; 149 150 <div class="form-group"> 151 <label class="label-lg" for="">@Translate("SmartPage:Event." + facet.GetString("Facet.Name"), facet.GetString("Facet.Name"))</label> 152 @foreach (var option in facet.GetLoop("FacetOptions").OrderBy(o => o.GetString("FacetOption.Value"))) 153 { 154 var optionLabel = GetTranslator(facet.GetString("Facet.Field"), option.GetString("FacetOption.Value")); 155 bool isSelected = false; 156 157 if(facet.GetString("Facet.RenderType") == "ResultsCheckboxes" && option.GetString("FacetOption.Value") == "RankingPoints" && !Converter.ToBoolean(Pageview.Area.Item["EnableRankingSystem"])) 158 { 159 continue; 160 } 161 162 if (facet.GetString("Facet.RenderType") == "RegionCheckboxes") 163 { 164 var facetChild = facets.FirstOrDefault(i => i.GetString("Facet.RenderType") == "DistrictCheckboxes"); 165 if (facetChild != null) 166 { 167 var districtProvider = new DistrictProvider(HttpContext.Current.Server, DataArea.Go); 168 var districts = districtProvider.GetDistrictsByRegionIdCached(option.GetString("FacetOption.Value")).Select(i => i.DistrictId).ToArray(); 169 170 foreach (var optionChild in facetChild.GetLoop("FacetOptions").Where(i => districts.Contains(i.GetString("FacetOption.Value")))) 171 { 172 if (optionChild.GetBoolean("FacetOption.Selected")) 173 { 174 isSelected = optionChild.GetBoolean("FacetOption.Selected"); 175 } 176 } 177 } 178 179 if(!isSelected) 180 { 181 isSelected = option.GetBoolean("FacetOption.Selected"); 182 } 183 } 184 else 185 { 186 isSelected = option.GetBoolean("FacetOption.Selected"); 187 } 188 189 <div class="form-check"> 190 <input type="checkbox" class="form-check-input js-onchange-submit js-onchange-uncheck" id="@("option-" + index)" name="@facet.GetString("Facet.QueryParameter")" value="@option.GetString("FacetOption.Value")" checked="@isSelected" /> 191 <label class="form-check-label" for="@("option-" + (index++))"> 192 @optionLabel 193 @if (showFacetOptionCount) 194 { 195 <span class="count">(@option.GetValue("FacetOption.Count"))</span> 196 } 197 </label> 198 </div> 199 200 if (isSelected && facet.GetString("Facet.RenderType") == "RegionCheckboxes") 201 { 202 var facetChild = facets.FirstOrDefault(i => i.GetString("Facet.RenderType") == "DistrictCheckboxes"); 203 if (facetChild != null) 204 { 205 var districtProvider = new DistrictProvider(HttpContext.Current.Server, DataArea.Go); 206 var districts = districtProvider.GetDistrictsByRegionIdCached(option.GetString("FacetOption.Value")).Select(i => i.DistrictId).ToArray(); 207 208 foreach (var optionChild in facetChild.GetLoop("FacetOptions").Where(i => districts.Contains(i.GetString("FacetOption.Value")))) 209 { 210 var optionChildLabel = GetTranslator(facetChild.GetString("Facet.Field"), optionChild.GetString("FacetOption.Value")); 211 212 <div class="form-check form-check-child"> 213 <input type="checkbox" class="form-check-input js-onchange-submit" id="@("option-" + index)" name="@facetChild.GetString("Facet.QueryParameter")" value="@optionChild.GetString("FacetOption.Value")" checked="@optionChild.GetBoolean("FacetOption.Selected")" /> 214 <label class="form-check-label" for="@("option-" + (index++))"> 215 @optionChildLabel 216 @if (showFacetOptionCount) 217 { 218 <span class="count">(@optionChild.GetValue("FacetOption.Count"))</span> 219 } 220 </label> 221 </div> 222 } 223 } 224 } 225 } 226 </div> 227 } 228 } 229 } 230 231 @helper renderAccordionRider(int registerStep = 1, string attrName = "rider") 232 { 233 var riderLoop = GetLoop("RiderLoop"); 234 235 <div class="accordion js-accordion js-checkmark" id="accordion-rider"> 236 <h4> 237 <span class="d-inline-block bullet" data-toggle="tooltip" data-trigger="click" data-placement="top" data-html="true" title="@GetString("SmartPage:Event.Rider.HelperText")">@registerStep</span> 238 @Translate("SmartPage:Event.ChooseRider", "Vælg rytter/person") 239 <span class="checkmark d-none"><i class="fas fa-check text-success"></i></span> 240 </h4> 241 <div class="form-group m-0"> 242 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseFavRider" aria-expanded="true" aria-controls="collapseFavRider"><i class="@("fas fa-chevron-" + (riderLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromRiders", "Vælg fra Mine Ryttere")</label> 243 <div id="collapseFavRider" class="@("collapse" + (riderLoop.Any() ? " show" : ""))" aria-labelledby="collapseFavRider" data-parent="#accordion-rider"> 244 <div class="mb-3"> 245 <select class="form-control form-control-sm select2-single js-select2" id="search-for-rider" name="@attrName" data-placeholder="@Translate("SmartPage:Event.ChooseOption", "Vælg...")" data-select2-MinimumResultsForSearch="-1" data-select2-AllowClear="true"> 246 @foreach (var i in riderLoop) 247 { 248 <option value="@i.GetString("SmartPage:RiderId")" selected="@i.GetBoolean("SmartPage:IsDefault")">@i.GetString("SmartPage:RiderName")</option> 249 } 250 </select> 251 </div> 252 </div> 253 </div> 254 <div class="form-group m-0"> 255 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseAllRiders" aria-expanded="true" aria-controls="collapseAllRiders"><i class="@("fas fa-chevron-" + (!riderLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromAllRiders", "Vælg blandt alle ryttere/personer")</label> 256 <div id="collapseAllRiders" class="@("collapse" + (!riderLoop.Any() ? " show" : ""))" aria-labelledby="collapseAllRiders" data-parent="#accordion-rider"> 257 <select class="form-control form-control-sm select2-single js-select2" id="search-all-rider" name="@attrName" data-placeholder="@Translate("SmartPage:Event.Rider.ChooseOption", "Indtast email eller DRF-nummer")" data-select2-provider="/services/ProfileService.asmx/GetRiderSuggestions?Rider=true"></select> 258 </div> 259 </div> 260 </div> 261 } 262 263 @helper renderAccordionHorse(int registerStep = 1, string attrName = "horse") 264 { 265 var horseLoop = GetLoop("HorseLoop"); 266 267 <div class="accordion js-accordion js-checkmark" id="accordion-horse"> 268 <h4> 269 <span class="d-inline-block bullet" data-toggle="tooltip" data-trigger="click" data-placement="top" data-html="true" title="@GetString("SmartPage:Event.Horse.HelperText")">@registerStep</span> 270 @Translate("SmartPage:Event.ChooseHorse", "Vælg hest") 271 <span class="checkmark d-none"><i class="fas fa-check text-success"></i></span> 272 </h4> 273 <div class="form-group m-0"> 274 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseFavHorse" aria-expanded="true" aria-controls="collapseFavHorse"><i class="@("fas fa-chevron-" + (horseLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromHorses", "Vælg fra Mine Heste")</label> 275 <div id="collapseFavHorse" class="@("collapse" + (horseLoop.Any() ? " show" : ""))" aria-labelledby="collapseFavHorse" data-parent="#accordion-horse"> 276 <div class="mb-3"> 277 <select class="form-control form-control-sm select2-single js-select2" id="search-for-horse" name="@attrName" data-placeholder="@Translate("SmartPage:Event.ChooseOption", "Vælg...")" data-select2-MinimumResultsForSearch="-1" data-select2-AllowClear="true"> 278 @foreach (var i in horseLoop) 279 { 280 <option value="@i.GetString("SmartPage:HorseId")" selected="@i.GetBoolean("SmartPage:IsDefault")">@i.GetString("SmartPage:HorseName") (@i.GetString("SmartPage:HorseDisplayId"))</option> 281 } 282 </select> 283 </div> 284 </div> 285 </div> 286 <div class="form-group m-0"> 287 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseAllHorses" aria-expanded="true" aria-controls="collapseAllHorses"><i class="@("fas fa-chevron-" + (!horseLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromAllHorses", "Vælg blandt alle heste")</label> 288 <div id="collapseAllHorses" class="@("collapse" + (!horseLoop.Any() ? " show" : ""))" aria-labelledby="collapseAllHorses" data-parent="#accordion-horse"> 289 <select class="form-control form-control-sm select2-single js-select2" id="search-all-horse" name="@attrName" data-placeholder="@Translate("SmartPage:Event.Horse.ChooseOption", "Indtast Id nummer")" data-select2-provider="/services/ProfileService.asmx/GetHorseSuggestions?Horse=true"></select> 290 </div> 291 </div> 292 </div> 293 } 294 295 @helper renderAccordionClub(int registerStep = 1, string attrName = "club") 296 { 297 var clubLoop = GetLoop("ClubLoop"); 298 299 <div class="accordion js-accordion js-checkmark" id="accordion-club"> 300 <h4> 301 <span class="d-inline-block bullet" data-toggle="tooltip" data-trigger="click" data-placement="top" data-html="true" title="@GetString("SmartPage:Event.Club.HelperText")">@registerStep</span> 302 @Translate("SmartPage:Event.ChooseClub", "Vælg klub") 303 <span class="checkmark d-none"><i class="fas fa-check text-success"></i></span> 304 </h4> 305 <div class="form-group m-0"> 306 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseFavClub" aria-expanded="true" aria-controls="collapseFavClub"><i class="@("fas fa-chevron-" + (clubLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromClubs", "Vælg fra Mine Klubber")</label> 307 <div id="collapseFavClub" class="@("collapse" + (clubLoop.Any() ? " show" : ""))" aria-labelledby="collapseFavClub" data-parent="#accordion-club"> 308 <div class="mb-3"> 309 <select class="form-control form-control-sm select2-single mb-3 js-select2" id="search-for-club" name="@attrName" data-placeholder="@Translate("SmartPage:Event.ChooseOption", "Vælg...")" data-select2-MinimumResultsForSearch="-1" data-select2-AllowClear="true"> 310 @foreach (var i in clubLoop) 311 { 312 <option value="@i.GetString("SmartPage:ClubId")" selected="@i.GetBoolean("SmartPage:IsDefault")">@i.GetString("SmartPage:ClubName")</option> 313 } 314 </select> 315 </div> 316 </div> 317 </div> 318 <div class="form-group m-0"> 319 <label class="accordion-toggle" data-toggle="collapse" data-target="#collapseAllClubs" aria-expanded="true" aria-controls="collapseAllClubs"><i class="@("fas fa-chevron-" + (!clubLoop.Any() ? "down" : "right"))"></i> @Translate("SmartPage:Event.ChooseFromAllClubs", "Vælg blandt alle klubber")</label> 320 <div id="collapseAllClubs" class="@("collapse" + (!clubLoop.Any() ? " show" : ""))" aria-labelledby="collapseAllClubs" data-parent="#accordion-club"> 321 <select class="form-control form-control-sm select2-single js-select2" id="search-all-club" name="@attrName" data-placeholder="@Translate("SmartPage:Event.Club.ChooseOption", "Indtast navn/fork")" data-select2-provider="@getPageUrlByNavigationTag("ClubSearchPage", "Club=true")"></select> 322 </div> 323 </div> 324 </div> 325 } 326 327 @helper renderAccordionComment(int registerStep = 1, string attrName = "comment") 328 { 329 <div> 330 <h4> 331 <span class="d-inline-block bullet" data-toggle="tooltip" data-trigger="click" data-placement="top" data-html="true" title="@GetString("SmartPage:Event.Club.HelperText")">@registerStep</span> 332 @Translate("SmartPage:Event.ChooseComments", "Bemærkning") 333 </h4> 334 <textarea class="form-control form-control-sm js-maxlength js-validate" id="comment" name="comment" maxlength="255" data-maxlength="#js-maxlength" data-validation-message="Du har indtastet et ugyldigt tegn i bemærknings feltet. Fjern tegnet og prøv igen."></textarea> 335 <span class="help-inline maxlength">Tegn tilbage <span id="js-maxlength"></span></span> 336 </div> 337 } 338 339 @helper renderPagination(int _pagecount, int _currentpage) 340 { 341 var groupAmount = 5; 342 var isDotsPrinted = false; 343 344 @*<ul class="pagination"> 345 <li class="page-item disabled"> 346 <a class="page-link" href="#" tabindex="-1">Previous</a> 347 </li> 348 <li class="page-item"><a class="page-link" href="#">1</a></li> 349 <li class="page-item active"> 350 <a class="page-link" href="#">2 <span class="sr-only">(current)</span></a> 351 </li> 352 <li class="page-item"><a class="page-link" href="#">3</a></li> 353 <li class="page-item"> 354 <a class="page-link" href="#">Next</a> 355 </li> 356 </ul>*@ 357 358 if (_pagecount > 1) 359 { 360 <ul class="pagination pagination-sm"> 361 @{ 362 if (_currentpage > 1) 363 { 364 <li class="page-item"><a href="@GetPaginatedLink(_currentpage - 1)" class="page-link">&lt; Forrige</a></li> 365 } 366 367 for (int i = 1; i <= _pagecount; i++) 368 { 369 if (i != _currentpage) 370 { 371 if (i == 1 || (i >= (_currentpage - 2) && (i < _currentpage || i <= groupAmount)) || (i <= (_currentpage + 2) && (i > _currentpage || i >= (_pagecount - groupAmount))) || i == _pagecount) 372 { 373 <li class="page-item"><a href="@GetPaginatedLink(i)" class="page-link" data-page="@i">@i</a></li> 374 } 375 else if (!isDotsPrinted) 376 { 377 <li class="page-item disabled"><span class="page-link">..</span></li> 378 isDotsPrinted = true; 379 } 380 } 381 else 382 { 383 <li class="page-item active"><a href="@GetPaginatedLink(i)" class="page-link" data-page="@i">@i</a></li> 384 isDotsPrinted = false; 385 } 386 } 387 388 if (_currentpage < _pagecount) 389 { 390 <li class="page-item"><a href="@GetPaginatedLink(_currentpage + 1)" class="page-link">Næste &gt;</a></li> 391 } 392 } 393 </ul> 394 } 395 } 396 397 @helper renderPageSizeDropdown(string _attributeId, int _currentPageSize, List<int> _availablePageSizes, bool showOptionAll) 398 { 399 var url = Converter.ToString(Context.Current.Request.RawUrl); 400 url = QueryHelper.ReplaceQueryStringParam(url, "pagenum", "1"); 401 <div class="pagination-size"> 402 <select class="form-control form-control-sm js-select2 js-onchange-href" id='@_attributeId' name="pagesize" autocomplete="off" data-select2-minimumResultsForSearch="-1"> 403 @foreach (var size in _availablePageSizes) 404 { 405 <option value="@QueryHelper.ReplaceQueryStringParam(url, "pagesize", Converter.ToString(size))" selected="@(size == _currentPageSize)">@string.Format(Translate("SmartPage:PageSize.Item", "vis {0}"), size)</option> 406 } 407 @if (showOptionAll) 408 { 409 <option value="@QueryHelper.ReplaceQueryStringParam(url, "pagesize", Converter.ToString(999999))" selected="@(999999 == _currentPageSize)">@Translate("SmartPage:PageSize.AllItems", "vis alle")</option> 410 } 411 </select> 412 </div> 413 } 414 415 @helper renderOrderByDropdown(string _attributeId, Dictionary<string, string> _availableOrderbys) 416 { 417 var urlPath = System.Web.HttpContext.Current.Request.Url.PathAndQuery; 418 419 <div class="pagination-orderby"> 420 @Translate("Smartpage:GlobalHelper.OrderBy.Label", "Sorter efter:")&nbsp;&nbsp; 421 </div> 422 <div class="pagination-orderby"> 423 <select class="form-control form-control-sm js-select2 js-onchange-href" id='@_attributeId' name="orderby" autocomplete="off" data-select2-minimumResultsForSearch="-1"> 424 @foreach (var option in _availableOrderbys) 425 { 426 <option value="@option.Value" selected="@(urlPath.ToLower() == option.Value.ToLower())">@option.Key</option> 427 } 428 </select> 429 </div> 430 } 431 432 @functions { 433 string displayMode(string defaultMode = "table") 434 { 435 if (!string.IsNullOrEmpty(Context.Current.Request.GetString("display-mode"))) 436 { 437 Context.Current.Session["SmartPage:Event.DisplayMode"] = Context.Current.Request.GetString("display-mode"); 438 } 439 else if (string.IsNullOrEmpty(Converter.ToString(Context.Current.Session["SmartPage:Event.DisplayMode"]))) 440 { 441 Context.Current.Session["SmartPage:Event.DisplayMode"] = defaultMode; 442 } 443 444 return Converter.ToString(Context.Current.Session["SmartPage:Event.DisplayMode"]); 445 } 446 } 447 448 @helper renderDisplayMode(string mode = "table") // options: 'table' and 'grid' 449 { 450 var url = Converter.ToString(Context.Current.Request.RawUrl); 451 452 <div class="list-display-type btn-group" role="group" aria-label="Display mode"> 453 <a href='@QueryHelper.ReplaceQueryStringParam(url, "display-mode", "table")' class="btn btn-secondary btn-sm" disabled="@(mode == "table")"><i class="fas fa-bars"></i></a> 454 <a href='@QueryHelper.ReplaceQueryStringParam(url, "display-mode", "grid")' class="btn btn-secondary btn-sm" disabled="@(mode == "grid")"><i class="fas fa-th"></i></a> 455 </div> 456 } 457 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 458 @using Dynamicweb; 459 @using Dynamicweb.Environment; 460 461 @helper RenderEventSearchBox() 462 { 463 var requestQ = Context.Current.Request.GetString("q"); 464 var requestEvent = Context.Current.Request.GetString("event"); 465 var requestEventId = Context.Current.Request.GetString("eventid"); 466 var requestClub = Context.Current.Request.GetString("club"); 467 var requestClubId = Context.Current.Request.GetString("clubid"); 468 469 <fieldset class="filter"> 470 <legend class="header">@Translate("SmartPage:EventHelper.SearchLegend", "Søg")</legend> 471 <div class="p-3"> 472 <div class="form-group"> 473 474 @if (!string.IsNullOrEmpty(requestEvent)) 475 { 476 if (!string.IsNullOrEmpty(requestEventId)) 477 { 478 <input type="hidden" class="js-select2-remove" name="EventId" value="@requestEventId" /> 479 } 480 481 <input type="hidden" class="js-select2-remove" name="Event" value="@requestEvent" /> 482 } 483 484 @if (!string.IsNullOrEmpty(requestClub)) 485 { 486 if (!string.IsNullOrEmpty(requestClubId)) 487 { 488 <input type="hidden" class="js-select2-remove" name="ClubId" value="@requestClubId" /> 489 } 490 491 <input type="hidden" class="js-select2-remove" name="Club" value="@requestClub" /> 492 } 493 494 <select class="form-control form-control-sm js-select2" id="search-for-event" name="q" data-placeholder="@Translate("SmartPage:Course.SearchDefault", "Arrangør/fork/navn")" data-select2-provider="@getPageUrlByNavigationTag("EventSearchPage", "Event=true&EventHeader=true&EventRedirect=true&Club=true&ClubHeader=true&ClubRedirect=true")" data-select2-Enablefreetext="true" required="@true"> 495 @if (!string.IsNullOrEmpty(requestEvent)) 496 { 497 <option value="@requestEvent" selected="@true">@requestEvent</option> 498 } 499 else if (!string.IsNullOrEmpty(requestClub)) 500 { 501 <option value="@requestClub" selected="@true">@requestClub</option> 502 } 503 else if (!string.IsNullOrEmpty(requestQ)) 504 { 505 <option value="@requestQ" selected="@true">@requestQ</option> 506 } 507 </select> 508 </div> 509 <div class="mt-2 text-right"> 510 <a href='@getPageUrlById()' class="btn btn-secondary btn-sm float-left" title="">@Translate("SmartPage:EventHelper.ClearFilter", "Nulstil kalender")</a> 511 <button type="submit" class="btn btn-primary btn-sm js-onsubmit-clear" id="search-event-button" data-onsubmit-clear="input[name='to']">@Translate("SmartPage:EventHelper.SearchButton", "Go!")</button> 512 </div> 513 </div> 514 </fieldset> 515 } 516 517 @{ 518 var results = GetLoop("QueryResultItem"); 519 List<int> resultsPageSizes = new List<int>() { { 30 }, { 60 }, { 90 } }; 520 var mode = displayMode(); 521 } 522 523 <div class="row"> 524 <h1 class="col-12">@Pageview.CurrentParagraph.Header <span id="entries-total">@(GetInteger("QueryResult.TotalCount") > 0 ? string.Format("({0})", GetString("QueryResult.TotalCount")) : "")</span></h1> 525 </div> 526 <div class="row"> 527 <div class="col-md-3 sidebar"> 528 <form class="js-form-facets" method="GET" action="@getPageUrlById()"> 529 <div class="shadow"> 530 @RenderEventSearchBox() 531 </div> 532 <div class="shadow p-3"> 533 @renderFacetEndDate(DateTime.Now.Date, (!Context.Current.Request.HasRequest("to") && (Context.Current.Request.HasRequest("event") || Context.Current.Request.HasRequest("club") || Context.Current.Request.HasRequest("q")) ? DateTime.MinValue : DateTime.Now.Date.AddMonths(3))) 534 @renderFacetGroups(true) 535 </div> 536 </form> 537 </div> 538 <div class="col-md-9"> 539 @if (results.Any()) 540 { 541 <div class="pagination-container pagination-top"> 542 <input id="pagesize" type="hidden" name="pageNum" value="@GetString("DwPaging.CurrentPage")" /> 543 @renderPagination(GetInteger("DwPaging.PageCount"), GetInteger("DwPaging.CurrentPage")) 544 @renderPageSizeDropdown("pagesize-top", GetInteger("DwPaging.PageSize"), resultsPageSizes, true) 545 @renderDisplayMode(mode) 546 </div> 547 548 if (mode == "table") 549 { 550 <table id="entries" class="table table-condensed table-hover table-striped clickable shadow responsive"> 551 <colgroup> 552 <col width="@((100/12)*5)%" /> 553 <col width="@((100/12)*4)%" /> 554 <col width="@((100/12)*3)%" /> 555 </colgroup> 556 <thead> 557 <tr> 558 <th>@Translate("SmartPage:Event.EventInformation", "Stævneinformation")</th> 559 <th>@Translate("SmartPage:Event.DateAndDeadline", "Dato & Anmeldelsesfrist")</th> 560 <th>@Translate("SmartPage:Event.DisciplineAndLevel", "Disciplin & Niveau")</th> 561 </tr> 562 </thead> 563 <tbody> 564 @foreach (LoopItem i in results) 565 { 566 var eventLink = getPageUrlByNavigationTag("EventPage", "EventId=" + i.GetString("EventId")); 567 568 <tr itemscope itemtype="http://schema.org/SportsEvent"> 569 <td> 570 <div class="club" itemprop="location" itemscope itemtype="http://schema.org/Place"> 571 <span class="org" itemprop="name">@i.GetString("ClubName").ToUpper()</span> (@i.GetString("DistrictKnownAs")) 572 <div class="adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> 573 <meta itemprop="streetAddress" content="@i.GetString("Address")" /> 574 <meta itemprop="postalCode" content="@i.GetString("ZipCode")" /> 575 <meta itemprop="addressLocality" content="@i.GetString("City")" /> 576 </div> 577 </div> 578 <div class="name" itemprop="name"> 579 <a href='@eventLink' itemprop="url">@i.GetString("EventName")</a> 580 @if (!string.IsNullOrEmpty(i.GetString("GameLevel"))) 581 { 582 <span class="gamelevel">(@i.GetString("GameLevel"))</span> 583 } 584 </div> 585 </td> 586 <td> 587 <div class="interval">@i.GetDate("StartDate").ToShortDateString() - @i.GetDate("EndDate").ToShortDateString()</div> 588 <meta itemprop="startDate" content="@i.GetDate("StartDate").ToString("o")" /> 589 <meta itemprop="endDate" content="@i.GetDate("EndDate").ToString("o")" /> 590 @if (i.GetDate("RegistrationDeadline").Date < DomainConstants.MaximumDate) 591 { 592 <span class="deadline">@i.GetDate("RegistrationDeadline").ToShortDateString()</span> 593 } 594 <span class="status"> 595 (@Translate("SmartPage:Event.EventStatus." + i.GetString("EventStatusEnum"), i.GetString("EventStatusEnum"))) 596 </span> 597 </td> 598 <td> 599 <ul class="disciplines"> 600 @if ((string[])i.GetValue("Disciplines") != null) 601 { 602 foreach (var j in (string[])i.GetValue("Disciplines")) 603 { 604 <li>@Translate("SmartPage:Event.Discipline." + j, j)</li> 605 } 606 } 607 </ul> 608 <div class="category"> 609 @Translate("SmartPage:Event.Category." + i.GetString("AnimalCategoryEnum"), i.GetString("AnimalCategoryEnum")) 610 </div> 611 </td> 612 </tr> 613 } 614 </tbody> 615 </table> 616 } 617 else 618 { 619 <div class="row" id="entries"> 620 @foreach (var i in results) 621 { 622 var eventLink = getPageUrlByNavigationTag("EventPage", "EventId=" + i.GetString("EventId")); 623 624 <div class="col-lg-4 event-grid-box"> 625 <div class="shadow" onclick="window.location='@eventLink'"> 626 <div class="event-header"> 627 <div class="event-label"> 628 <span class="month"> 629 @i.GetDate("StartDate").ToString("MMM") 630 </span> 631 <br /> 632 <span class="year"> 633 @i.GetDate("StartDate").ToString("yyyy") 634 </span> 635 </div> 636 <div class="event-short-info"> 637 <span class="date-interval"> 638 @i.GetDate("StartDate").ToShortDateString() - @i.GetDate("EndDate").ToShortDateString() 639 </span> 640 <p class="club">@i.GetString("ClubName").ToUpper()</p> 641 </div> 642 </div> 643 <p class="name">@i.GetString("EventName")</p> 644 <table> 645 <tr> 646 <th>@Translate("Smartpage:Results.District", "Distrikt")</th> 647 <td>@i.GetString("DistrictKnownAs")</td> 648 </tr> 649 @if (!i.GetBoolean("SmartPage:Event.IsPonyMeasurement")) 650 { 651 <tr> 652 <th>@Translate("Smartpage:Results.Disciplin", "Disciplin")</th> 653 <td> 654 <ul class="disciplines"> 655 @foreach (var j in (string[])i.GetValue("Disciplines")) 656 { 657 <li>@Translate("SmartPage:Event.Discipline." + j, j)</li> 658 } 659 </ul> 660 </td> 661 </tr> 662 } 663 <tr> 664 <th>@Translate("Smartpage:Results.Niveau", "Niveau")</th> 665 <td>@i.GetString("GameLevel")</td> 666 </tr> 667 <tr> 668 <th>@Translate("Smartpage:Results.Type", "Type")</th> 669 <td>@Translate("SmartPage:Event.Category." + i.GetString("AnimalCategoryEnum"), i.GetString("AnimalCategoryEnum"))</td> 670 </tr> 671 </table> 672 @*<p class="deadline hide">Frist: @i.GetString("SmartPage:Event.Deadline")</p>*@ 673 </div> 674 </div> 675 } 676 </div> 677 } 678 679 <div class="pagination-container pagination-bottom"> 680 @renderPagination(GetInteger("DwPaging.PageCount"), GetInteger("DwPaging.CurrentPage")) 681 @renderPageSizeDropdown("pagesize-bottom", GetInteger("DwPaging.PageSize"), resultsPageSizes, true) 682 @renderDisplayMode(mode) 683 </div> 684 } 685 else 686 { 687 <div class="content shadow"> 688 @Pageview.CurrentParagraph.Text 689 </div> 690 } 691 </div> 692 </div>