Error compiling template "Designs/Swift/_parsed/Swift_Preferences.parsed.cshtml"
Line 66: 'Country' does not contain a definition for 'Name' and no accessible extension method 'Name' accepting a first argument of type 'Country' could be found (are you missing a using directive or an assembly reference?)

1 // <auto-generated/> 2 #pragma warning disable 1591 3 namespace CompiledRazorTemplates.Dynamic 4 { 5 #line hidden 6 using System.Threading.Tasks; 7 using System.Collections.Generic; 8 using System.Linq; 9 using System; 10 using System.Text.RegularExpressions; 11 using System.IO; 12 internal class RazorEngine_3ee8794518594a528ea1047e323ab2ab : Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 13 { 14 #pragma warning disable 1998 15 public async override global::System.Threading.Tasks.Task ExecuteAsync() 16 { 17 WriteLiteral("\r\n\r\n\r\n"); 18 19 string layout = Model.Item.GetRawValueString("PreferencesLayout", "modal"); 20 layout = Dynamicweb.Context.Current.Request["Layout"] != null ? Dynamicweb.Context.Current.Request["Layout"] : layout; 21 layout = layout == "" ? "modal" : layout; 22 string type = Dynamicweb.Context.Current.Request["Type"] != null ? Dynamicweb.Context.Current.Request["Type"] : "language"; 23 24 string groupId = Dynamicweb.Context.Current.Request["GroupID"] != null ? Dynamicweb.Context.Current.Request["GroupID"].ToString() : ""; 25 string productId = Dynamicweb.Context.Current.Request["ProductID"] != null ? Dynamicweb.Context.Current.Request["ProductID"].ToString() : ""; 26 string variantId = Dynamicweb.Context.Current.Request["VariantID"] != null ? Dynamicweb.Context.Current.Request["VariantID"].ToString() : ""; 27 28 string linkFontSize = Dynamicweb.Context.Current.Request["FontSize"] != null ? Dynamicweb.Context.Current.Request["FontSize"].ToString() : ""; 29 string linkFontWeight = Dynamicweb.Context.Current.Request["FontWeight"] != null ? Dynamicweb.Context.Current.Request["FontWeight"].ToString() : ""; 30 string linkCasing = Dynamicweb.Context.Current.Request["Casing"] != null ? Dynamicweb.Context.Current.Request["Casing"].ToString() : ""; 31 32 Regex reg = new Regex(@"\(([^\)]+)\)"); 33 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>(); 34 35 int pageId = Dynamicweb.Context.Current.Request["CurrentPageID"] != null ? Convert.ToInt32(Dynamicweb.Context.Current.Request["CurrentPageID"]) : Pageview.ID; 36 var currentPage = Dynamicweb.Content.Services.Pages.GetPage(pageId); //Get the correct page instance 37 38 if (currentPage.Area.IsMaster) { 39 languages.Add(currentPage); 40 if (currentPage.Languages != null) { 41 foreach (var language in currentPage.Languages) { 42 if (language.Area.Active == true) { 43 languages.Add(language); 44 } 45 } 46 } 47 } else { 48 languages.Add(currentPage.MasterPage); 49 if (currentPage.MasterPage != null) { 50 if (currentPage.MasterPage.Languages != null) { 51 foreach (var language in currentPage.MasterPage.Languages) { 52 if (language.Area.Active == true) { 53 languages.Add(language); 54 } 55 } 56 } 57 } 58 } 59 60 languages = languages.Count > 1 ? languages.OrderBy(language => language.Area.CultureInfo.DisplayName).ToList() : languages; 61 62 string siteLanguage = Pageview.Area.CultureInfo.Name; 63 Uri url = Dynamicweb.Context.Current.Request.Url; 64 string hostName = url.Host; // domain.com/da-dk or domain.com/en-us 65 66 var ecomCountries = Dynamicweb.Ecommerce.Services.Countries.GetCountries() != null ? Dynamicweb.Ecommerce.Services.Countries.GetCountries().OrderBy(country => country.Name) : null; 67 var currencies = Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies() != null ? Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies().OrderBy(currency => currency.Code) : null; 68 69 string modalTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ModalTheme")) ? " theme " + Model.Item.GetRawValueString("ModalTheme").Replace(" ", "").Trim().ToLower() : ""; 70 WriteLiteral("\r\n"); 71 WriteLiteral("\r\n"); 72 if (layout == "modal") 73 { 74 int updatePageId = pageId; 75 76 WriteLiteral("\t<div"); 77 BeginWriteAttribute("class", " class=\"", 3410, "\"", 3481, 4); 78 WriteAttributeValue("", 3418, "modal-content", 3418, 13, true); 79 WriteAttributeValue(" ", 3431, modalTheme, 3432, 11, false); 80 WriteAttributeValue(" ", 3443, "item_", 3444, 6, true); 81 WriteAttributeValue("", 3449, Model.Item.SystemName.ToLower(), 3449, 32, false); 82 EndWriteAttribute(); 83 WriteLiteral(">\r\n\t\t<div class=\"modal-header\">\r\n\t\t\t<h5 class=\"modal-title\" id=\"PreferencesModalLabel\">"); 84 Write(Translate("Preferences")); 85 WriteLiteral("</h5>\r\n\t\t\t<button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" aria-label=\"Close\"></button>\r\n\t\t</div>\r\n\t\t<div class=\"modal-body d-grid gap-3\" id=\"PreferencesModalBody\">\r\n\t\t\t<input type=\"hidden\" name=\"CurrentPageID\""); 86 BeginWriteAttribute("value", " value=\"", 3819, "\"", 3834, 1); 87 WriteAttributeValue("", 3827, pageId, 3827, 7, false); 88 EndWriteAttribute(); 89 WriteLiteral(">\r\n"); 90 if (groupId != "") { 91 WriteLiteral("\t\t\t\t<input type=\"hidden\" name=\"GroupID\""); 92 BeginWriteAttribute("value", " value=\"", 3903, "\"", 3919, 1); 93 WriteAttributeValue("", 3911, groupId, 3911, 8, false); 94 EndWriteAttribute(); 95 WriteLiteral(">\r\n"); 96 } 97 WriteLiteral("\r\n"); 98 if (productId != "") { 99 WriteLiteral("\t\t\t\t<input type=\"hidden\" name=\"ProductID\""); 100 BeginWriteAttribute("value", " value=\"", 4000, "\"", 4018, 1); 101 WriteAttributeValue("", 4008, productId, 4008, 10, false); 102 EndWriteAttribute(); 103 WriteLiteral(">\r\n"); 104 } 105 WriteLiteral("\r\n"); 106 if (variantId != "") { 107 WriteLiteral("\t\t\t\t<input type=\"hidden\" name=\"VariantID\""); 108 BeginWriteAttribute("value", " value=\"", 4099, "\"", 4117, 1); 109 WriteAttributeValue("", 4107, variantId, 4107, 10, false); 110 EndWriteAttribute(); 111 WriteLiteral(">\r\n"); 112 } 113 WriteLiteral("\r\n\t\t\r\n"); 114 if (languages.Count() > 1 && Model.Item.GetBoolean("LanguageSelector")) 115 { 116 WriteLiteral(@" <form action=""/Default.aspx"" data-response-target-element=""PreferencesModalContent"" data-layout-template=""Swift_Preferences.cshtml"" data-preloader=""inline""> 117 <input type=""hidden"" name=""Layout"" value=""modal""> 118 <input type=""hidden"" name=""CurrentPageID"""); 119 BeginWriteAttribute("value", " value=\"", 4480, "\"", 4495, 1); 120 WriteAttributeValue("", 4488, pageId, 4488, 7, false); 121 EndWriteAttribute(); 122 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"GroupID\""); 123 BeginWriteAttribute("value", " value=\"", 4539, "\"", 4555, 1); 124 WriteAttributeValue("", 4547, groupId, 4547, 8, false); 125 EndWriteAttribute(); 126 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"ProductID\""); 127 BeginWriteAttribute("value", " value=\"", 4601, "\"", 4619, 1); 128 WriteAttributeValue("", 4609, productId, 4609, 10, false); 129 EndWriteAttribute(); 130 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"VariantID\""); 131 BeginWriteAttribute("value", " value=\"", 4665, "\"", 4683, 1); 132 WriteAttributeValue("", 4673, variantId, 4673, 10, false); 133 EndWriteAttribute(); 134 WriteLiteral(">\r\n\r\n\t\t\t\t\t<div class=\"form-floating\">\r\n\t\t\t\t\t\t<select id=\"LanguageSelect\" name=\"ID\" class=\"form-select d-col-12\""); 135 BeginWriteAttribute("aria-label", " aria-label=\"", 4795, "\"", 4837, 1); 136 WriteAttributeValue("", 4808, Translate("Select language"), 4808, 29, false); 137 EndWriteAttribute(); 138 WriteLiteral(" onchange=\"swift.PageUpdater.Update(event)\">\r\n"); 139 foreach (var language in languages) 140 { 141 if (language != null && language.Published && language.Area.Active && language.Area.Published) { 142 string selectedLanguage = language.Area.ID == Pageview.Area.ID ? "selected" : ""; 143 updatePageId = language.Area.ID == Pageview.Area.ID ? language.ID : updatePageId; 144 145 var masterPageId = Pageview.Page?.MasterPageId != null && Pageview.Page.MasterPageId != 0 ? Pageview.Page.MasterPageId : Pageview.ID; 146 var preferencePageId = Dynamicweb.Content.Services.Pages.GetPageIDByMasterID(masterPageId, language.AreaId); 147 preferencePageId = preferencePageId == 0 ? Pageview.Page.MasterPageId : preferencePageId; 148 preferencePageId = preferencePageId == 0 ? Pageview.Page.ID : preferencePageId; 149 150 WriteLiteral("\t\t\t\t\t\t\t\t\t<option"); 151 BeginWriteAttribute("hreflang", " hreflang=\"", 5702, "\"", 5764, 1); 152 WriteAttributeValue("", 5713, language.Area.CultureInfo.TwoLetterISOLanguageName, 5713, 51, false); 153 EndWriteAttribute(); 154 BeginWriteAttribute("value", " value=\"", 5765, "\"", 5790, 1); 155 WriteAttributeValue("", 5773, preferencePageId, 5773, 17, false); 156 EndWriteAttribute(); 157 WriteLiteral(" "); 158 Write(selectedLanguage); 159 WriteLiteral(">"); 160 Write(language.Area.DisplayName); 161 WriteLiteral("</option>\r\n"); 162 } 163 } 164 WriteLiteral("\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t<label for=\"LanguageSelect\">"); 165 Write(Translate("Language")); 166 WriteLiteral("</label>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</form>\r\n"); 167 } 168 WriteLiteral("\r\n"); 169 if (ecomCountries.Count() > 1 && Model.Item.GetBoolean("CountrySelector")) 170 { 171 WriteLiteral("\t\t\t\t<form action=\"/Default.aspx\" data-response-target-element=\"PreferencesModalContent\" data-layout-template=\"Swift_Preferences.cshtml\" data-preloader=\"inline\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"ID\""); 172 BeginWriteAttribute("value", " value=\"", 6268, "\"", 6288, 1); 173 WriteAttributeValue("", 6276, Pageview.ID, 6276, 12, false); 174 EndWriteAttribute(); 175 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"CurrentPageID\""); 176 BeginWriteAttribute("value", " value=\"", 6338, "\"", 6353, 1); 177 WriteAttributeValue("", 6346, pageId, 6346, 7, false); 178 EndWriteAttribute(); 179 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"GroupID\""); 180 BeginWriteAttribute("value", " value=\"", 6397, "\"", 6413, 1); 181 WriteAttributeValue("", 6405, groupId, 6405, 8, false); 182 EndWriteAttribute(); 183 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"ProductID\""); 184 BeginWriteAttribute("value", " value=\"", 6459, "\"", 6477, 1); 185 WriteAttributeValue("", 6467, productId, 6467, 10, false); 186 EndWriteAttribute(); 187 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"VariantID\""); 188 BeginWriteAttribute("value", " value=\"", 6523, "\"", 6541, 1); 189 WriteAttributeValue("", 6531, variantId, 6531, 10, false); 190 EndWriteAttribute(); 191 WriteLiteral(">\r\n\r\n\t\t\t\t\t<div class=\"form-floating\">\r\n\t\t\t\t\t\t<select name=\"CountryCode\" id=\"CountryCodeSelect\" class=\"form-select d-col-12\""); 192 BeginWriteAttribute("aria-label", " aria-label=\"", 6665, "\"", 6706, 1); 193 WriteAttributeValue("", 6678, Translate("Select country"), 6678, 28, false); 194 EndWriteAttribute(); 195 WriteLiteral(" onchange=\"swift.PageUpdater.Update(event)\">\r\n"); 196 foreach (var country in ecomCountries) 197 { 198 var selectedCountry = country.Code2 == Dynamicweb.Ecommerce.Common.Context.Country.Code2 ? "selected" : ""; 199 200 if (!string.IsNullOrEmpty(country.Name)) { 201 WriteLiteral("\t\t\t\t\t\t\t\t\t<option"); 202 BeginWriteAttribute("value", " value=\"", 6999, "\"", 7021, 1); 203 WriteAttributeValue("", 7007, country.Code2, 7007, 14, false); 204 EndWriteAttribute(); 205 WriteLiteral(" "); 206 Write(selectedCountry); 207 WriteLiteral(">"); 208 Write(country.Name); 209 WriteLiteral("</option>\r\n"); 210 } 211 } 212 WriteLiteral("\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t<label for=\"CountryCodeSelect\">"); 213 Write(Translate("Delivery country")); 214 WriteLiteral("</label>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</form>\r\n"); 215 } 216 WriteLiteral("\r\n"); 217 if (currencies.Count() > 1 && Model.Item.GetBoolean("CurrencySelector")) 218 { 219 WriteLiteral("\t\t\t\t<form action=\"/Default.aspx\" data-response-target-element=\"PreferencesModalContent\" data-layout-template=\"Swift_Preferences.cshtml\" data-preloader=\"inline\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"ID\""); 220 BeginWriteAttribute("value", " value=\"", 7494, "\"", 7514, 1); 221 WriteAttributeValue("", 7502, Pageview.ID, 7502, 12, false); 222 EndWriteAttribute(); 223 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"CurrentPageID\""); 224 BeginWriteAttribute("value", " value=\"", 7564, "\"", 7579, 1); 225 WriteAttributeValue("", 7572, pageId, 7572, 7, false); 226 EndWriteAttribute(); 227 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"GroupID\""); 228 BeginWriteAttribute("value", " value=\"", 7623, "\"", 7639, 1); 229 WriteAttributeValue("", 7631, groupId, 7631, 8, false); 230 EndWriteAttribute(); 231 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"ProductID\""); 232 BeginWriteAttribute("value", " value=\"", 7685, "\"", 7703, 1); 233 WriteAttributeValue("", 7693, productId, 7693, 10, false); 234 EndWriteAttribute(); 235 WriteLiteral(">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"VariantID\""); 236 BeginWriteAttribute("value", " value=\"", 7749, "\"", 7767, 1); 237 WriteAttributeValue("", 7757, variantId, 7757, 10, false); 238 EndWriteAttribute(); 239 WriteLiteral(">\r\n\r\n\t\t\t\t\t<div class=\"form-floating\">\r\n\t\t\t\t\t\t<select name=\"CurrencyCode\" id=\"CurrencySelect\" class=\"form-select d-col-12\""); 240 BeginWriteAttribute("aria-label", " aria-label=\"", 7889, "\"", 7931, 1); 241 WriteAttributeValue("", 7902, Translate("Select currency"), 7902, 29, false); 242 EndWriteAttribute(); 243 WriteLiteral(" onchange=\"swift.PageUpdater.Update(event)\">\r\n"); 244 foreach (var currency in currencies) 245 { 246 string selectedCurrency = currency.Code == Dynamicweb.Ecommerce.Common.Context.Currency.Code ? "selected" : ""; 247 248 if (!string.IsNullOrEmpty(currency.Code)) { 249 WriteLiteral("\t\t\t\t\t\t\t\t\t<option"); 250 BeginWriteAttribute("value", " value=\"", 8227, "\"", 8249, 1); 251 WriteAttributeValue("", 8235, currency.Code, 8235, 14, false); 252 EndWriteAttribute(); 253 WriteLiteral(" "); 254 Write(selectedCurrency); 255 WriteLiteral(">"); 256 Write(currency.Code); 257 WriteLiteral("</option>\r\n"); 258 } 259 } 260 WriteLiteral("\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t<label for=\"CurrencySelect\">"); 261 Write(Translate("Currency")); 262 WriteLiteral("</label>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</form>\r\n"); 263 } 264 WriteLiteral("\t\t</div>\r\n\t\t<div class=\"modal-footer\">\r\n"); 265 266 hostName = !string.IsNullOrEmpty(Pageview.Area.DomainLock) ? Pageview.Area.DomainLock : url.Host; 267 string link = $"Default.aspx?ID={updatePageId}"; 268 link += groupId != "" ? $"&GroupID={groupId}" : ""; 269 link += productId != "" ? $"&ProductID={productId}" : ""; 270 link += variantId != "" ? $"&VariantID={variantId}" : ""; 271 var friendlyUrl = $"{url.Scheme}://{hostName}{Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(link)}"; 272 WriteLiteral("\r\n\t\t\t<a"); 273 BeginWriteAttribute("href", " href=\"", 8951, "\"", 8970, 1); 274 WriteAttributeValue("", 8958, friendlyUrl, 8958, 12, false); 275 EndWriteAttribute(); 276 WriteLiteral(" class=\"btn btn-primary w-100\">"); 277 Write(Translate("Update preferences")); 278 WriteLiteral("</a>\r\n\t\t</div>\r\n\t</div>\r\n"); 279 } 280 281 WriteLiteral("\r\n"); 282 if (layout == "dropdown" && type == "country") { 283 foreach (var country in ecomCountries) 284 { 285 var link = $"{url.Scheme}://{hostName}?ID={currentPage.ID}&AreaID={Pageview.Area.ID}&CountryCode={country.Code2}"; 286 link += groupId != "" ? $"&GroupID={groupId}" : ""; 287 link += productId != "" ? $"&ProductID={productId}" : ""; 288 link += variantId != "" ? $"&VariantID={variantId}" : ""; 289 290 if (!string.IsNullOrEmpty(country.Name)) { 291 WriteLiteral("\t\t\t<li>\r\n\t\t\t\t<a"); 292 BeginWriteAttribute("href", " href=\"", 9537, "\"", 9549, 1); 293 WriteAttributeValue("", 9544, link, 9544, 5, false); 294 EndWriteAttribute(); 295 BeginWriteAttribute("class", " class=\"", 9550, "\"", 9632, 5); 296 WriteAttributeValue("", 9558, "dropdown-item", 9558, 13, true); 297 WriteAttributeValue(" ", 9571, "nav-link-underline", 9572, 19, true); 298 WriteAttributeValue(" ", 9590, linkFontSize, 9591, 13, false); 299 WriteAttributeValue(" ", 9604, linkFontWeight, 9605, 15, false); 300 WriteAttributeValue(" ", 9620, linkCasing, 9621, 11, false); 301 EndWriteAttribute(); 302 WriteLiteral(">"); 303 Write(country.Name); 304 WriteLiteral("</a>\r\n\t\t\t</li>\r\n"); 305 } 306 } 307 } 308 WriteLiteral("\r\n"); 309 if (layout == "dropdown" && type == "language") { 310 string iconFolder = "/Files/FlagIcons/"; 311 int languagesCount = 0; 312 313 foreach (var language in languages) 314 { 315 if (language.Area != null) { 316 if (language != null && language.Published && language.Area.Active && language.Area.Published && language.Area.ID != Dynamicweb.Frontend.PageView.Current().AreaID) { 317 hostName = !string.IsNullOrEmpty(language.Area.DomainLock) ? language.Area.DomainLock : url.Host; 318 string link = $"Default.aspx?ID={language.ID}"; 319 link += groupId != "" ? $"&GroupID={groupId}" : ""; 320 link += productId != "" ? $"&ProductID={productId}" : ""; 321 link += variantId != "" ? $"&VariantID={variantId}" : ""; 322 323 var friendlyUrl = $"{url.Scheme}://{hostName}{Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(link)}"; 324 325 string icon = iconFolder + language.Area.CultureInfo.Name.ToLower() + ".svg"; 326 WriteLiteral("\t\t\t\t<li>\r\n\t\t\t\t\t<a"); 327 BeginWriteAttribute("hreflang", " hreflang=\"", 10607, "\"", 10669, 1); 328 WriteAttributeValue("", 10618, language.Area.CultureInfo.TwoLetterISOLanguageName, 10618, 51, false); 329 EndWriteAttribute(); 330 BeginWriteAttribute("href", " href=\"", 10670, "\"", 10689, 1); 331 WriteAttributeValue("", 10677, friendlyUrl, 10677, 12, false); 332 EndWriteAttribute(); 333 BeginWriteAttribute("class", " class=\"", 10690, "\"", 10772, 5); 334 WriteAttributeValue("", 10698, "dropdown-item", 10698, 13, true); 335 WriteAttributeValue(" ", 10711, "nav-link-underline", 10712, 19, true); 336 WriteAttributeValue(" ", 10730, linkFontSize, 10731, 13, false); 337 WriteAttributeValue(" ", 10744, linkFontWeight, 10745, 15, false); 338 WriteAttributeValue(" ", 10760, linkCasing, 10761, 11, false); 339 EndWriteAttribute(); 340 WriteLiteral("><text>"); 341 RenderIcon(icon, "icon-2");WriteLiteral("</text> <span class=\"align-middle\">"); 342 Write(language.Area.DisplayName); 343 WriteLiteral("</span></a>\r\n\t\t\t\t</li>\r\n"); 344 345 languagesCount++; 346 } 347 } 348 } 349 350 if (languagesCount == 0) { 351 WriteLiteral("\t\t<li>\r\n\t\t\t<span class=\"dropdown-item fs-7 fw-normal\">\r\n\t\t\t\t"); 352 Write(Translate("Page is not translated")); 353 WriteLiteral("\r\n\t\t\t</span>\r\n\t\t</li>\r\n"); 354 } 355 } 356 WriteLiteral("\r\n"); 357 if (layout == "dropdown" && type == "currency") { 358 foreach (var currency in currencies) 359 { 360 var link = $"{url.Scheme}://{hostName}?ID={currentPage.ID}&AreaID={Pageview.Area.ID}&CurrencyCode={currency.Code}"; 361 link += groupId != "" ? $"&GroupID={groupId}" : ""; 362 link += productId != "" ? $"&ProductID={productId}" : ""; 363 link += variantId != "" ? $"&VariantID={variantId}" : ""; 364 365 WriteLiteral("\t\t<li>\r\n\t\t\t<a"); 366 BeginWriteAttribute("href", " href=\"", 11501, "\"", 11513, 1); 367 WriteAttributeValue("", 11508, link, 11508, 5, false); 368 EndWriteAttribute(); 369 BeginWriteAttribute("class", " class=\"", 11514, "\"", 11596, 5); 370 WriteAttributeValue("", 11522, "dropdown-item", 11522, 13, true); 371 WriteAttributeValue(" ", 11535, "nav-link-underline", 11536, 19, true); 372 WriteAttributeValue(" ", 11554, linkFontSize, 11555, 13, false); 373 WriteAttributeValue(" ", 11568, linkFontWeight, 11569, 15, false); 374 WriteAttributeValue(" ", 11584, linkCasing, 11585, 11, false); 375 EndWriteAttribute(); 376 WriteLiteral(">"); 377 Write(currency.Code); 378 WriteLiteral("</a>\r\n\t\t</li>\r\n"); 379 } 380 } 381 WriteLiteral("\r\n"); 382 WriteLiteral("\r\n"); 383 } 384 #pragma warning restore 1998 385 386 void RenderIcon(string icon, string iconSize) 387 { 388 if (Path.GetExtension(icon).ToLower() == ".svg" && !icon.ToLower().Contains("none")) 389 { 390 string iconPath = Dynamicweb.Context.Current.Server.MapPath(icon); 391 392 WriteLiteral("\t\t<span"); 393 BeginWriteAttribute("class", " class=\"", 11872, "\"", 11889, 1); 394 WriteAttributeValue("", 11880, iconSize, 11880, 9, false); 395 EndWriteAttribute(); 396 WriteLiteral(">\r\n\t\t\t"); 397 Write(ReadFile(iconPath)); 398 WriteLiteral("\r\n\t\t</span>\r\n"); 399 } 400 } 401 } 402 } 403 #pragma warning restore 1591 404

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 2 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 3 @using System 4 @using System.Text.RegularExpressions 5 @using System.IO 6 7 8 9 @{ 10 string layout = Model.Item.GetRawValueString("PreferencesLayout", "modal"); 11 layout = Dynamicweb.Context.Current.Request["Layout"] != null ? Dynamicweb.Context.Current.Request["Layout"] : layout; 12 layout = layout == "" ? "modal" : layout; 13 string type = Dynamicweb.Context.Current.Request["Type"] != null ? Dynamicweb.Context.Current.Request["Type"] : "language"; 14 15 string groupId = Dynamicweb.Context.Current.Request["GroupID"] != null ? Dynamicweb.Context.Current.Request["GroupID"].ToString() : ""; 16 string productId = Dynamicweb.Context.Current.Request["ProductID"] != null ? Dynamicweb.Context.Current.Request["ProductID"].ToString() : ""; 17 string variantId = Dynamicweb.Context.Current.Request["VariantID"] != null ? Dynamicweb.Context.Current.Request["VariantID"].ToString() : ""; 18 19 string linkFontSize = Dynamicweb.Context.Current.Request["FontSize"] != null ? Dynamicweb.Context.Current.Request["FontSize"].ToString() : ""; 20 string linkFontWeight = Dynamicweb.Context.Current.Request["FontWeight"] != null ? Dynamicweb.Context.Current.Request["FontWeight"].ToString() : ""; 21 string linkCasing = Dynamicweb.Context.Current.Request["Casing"] != null ? Dynamicweb.Context.Current.Request["Casing"].ToString() : ""; 22 23 Regex reg = new Regex(@"\(([^\)]+)\)"); 24 List<Dynamicweb.Content.Page> languages = new List<Dynamicweb.Content.Page>(); 25 26 int pageId = Dynamicweb.Context.Current.Request["CurrentPageID"] != null ? Convert.ToInt32(Dynamicweb.Context.Current.Request["CurrentPageID"]) : Pageview.ID; 27 var currentPage = Dynamicweb.Content.Services.Pages.GetPage(pageId); //Get the correct page instance 28 29 if (currentPage.Area.IsMaster) { 30 languages.Add(currentPage); 31 if (currentPage.Languages != null) { 32 foreach (var language in currentPage.Languages) { 33 if (language.Area.Active == true) { 34 languages.Add(language); 35 } 36 } 37 } 38 } else { 39 languages.Add(currentPage.MasterPage); 40 if (currentPage.MasterPage != null) { 41 if (currentPage.MasterPage.Languages != null) { 42 foreach (var language in currentPage.MasterPage.Languages) { 43 if (language.Area.Active == true) { 44 languages.Add(language); 45 } 46 } 47 } 48 } 49 } 50 51 languages = languages.Count > 1 ? languages.OrderBy(language => language.Area.CultureInfo.DisplayName).ToList() : languages; 52 53 string siteLanguage = Pageview.Area.CultureInfo.Name; 54 Uri url = Dynamicweb.Context.Current.Request.Url; 55 string hostName = url.Host; // domain.com/da-dk or domain.com/en-us 56 57 var ecomCountries = Dynamicweb.Ecommerce.Services.Countries.GetCountries() != null ? Dynamicweb.Ecommerce.Services.Countries.GetCountries().OrderBy(country => country.Name) : null; 58 var currencies = Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies() != null ? Dynamicweb.Ecommerce.Services.Currencies.GetAllCurrencies().OrderBy(currency => currency.Code) : null; 59 60 string modalTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ModalTheme")) ? " theme " + Model.Item.GetRawValueString("ModalTheme").Replace(" ", "").Trim().ToLower() : ""; 61 } 62 63 @* Modal *@ 64 65 @if (layout == "modal") 66 { 67 int updatePageId = pageId; 68 69 <div class="modal-content @modalTheme item_@Model.Item.SystemName.ToLower()"> 70 <div class="modal-header"> 71 <h5 class="modal-title" id="PreferencesModalLabel">@Translate("Preferences")</h5> 72 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 73 </div> 74 <div class="modal-body d-grid gap-3" id="PreferencesModalBody"> 75 <input type="hidden" name="CurrentPageID" value="@pageId"> 76 @if (groupId != "") { 77 <input type="hidden" name="GroupID" value="@groupId"> 78 } 79 80 @if (productId != "") { 81 <input type="hidden" name="ProductID" value="@productId"> 82 } 83 84 @if (variantId != "") { 85 <input type="hidden" name="VariantID" value="@variantId"> 86 } 87 88 89 @if (languages.Count() > 1 && Model.Item.GetBoolean("LanguageSelector")) 90 { 91 <form action="/Default.aspx" data-response-target-element="PreferencesModalContent" data-layout-template="Swift_Preferences.cshtml" data-preloader="inline"> 92 <input type="hidden" name="Layout" value="modal"> 93 <input type="hidden" name="CurrentPageID" value="@pageId"> 94 <input type="hidden" name="GroupID" value="@groupId"> 95 <input type="hidden" name="ProductID" value="@productId"> 96 <input type="hidden" name="VariantID" value="@variantId"> 97 98 <div class="form-floating"> 99 <select id="LanguageSelect" name="ID" class="form-select d-col-12" aria-label="@Translate("Select language")" onchange="swift.PageUpdater.Update(event)"> 100 @foreach (var language in languages) 101 { 102 if (language != null && language.Published && language.Area.Active && language.Area.Published) { 103 string selectedLanguage = language.Area.ID == Pageview.Area.ID ? "selected" : ""; 104 updatePageId = language.Area.ID == Pageview.Area.ID ? language.ID : updatePageId; 105 106 var masterPageId = Pageview.Page?.MasterPageId != null && Pageview.Page.MasterPageId != 0 ? Pageview.Page.MasterPageId : Pageview.ID; 107 var preferencePageId = Dynamicweb.Content.Services.Pages.GetPageIDByMasterID(masterPageId, language.AreaId); 108 preferencePageId = preferencePageId == 0 ? Pageview.Page.MasterPageId : preferencePageId; 109 preferencePageId = preferencePageId == 0 ? Pageview.Page.ID : preferencePageId; 110 111 <option hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName" value="@preferencePageId" @selectedLanguage>@language.Area.DisplayName</option> 112 } 113 } 114 </select> 115 <label for="LanguageSelect">@Translate("Language")</label> 116 </div> 117 </form> 118 } 119 120 @if (ecomCountries.Count() > 1 && Model.Item.GetBoolean("CountrySelector")) 121 { 122 <form action="/Default.aspx" data-response-target-element="PreferencesModalContent" data-layout-template="Swift_Preferences.cshtml" data-preloader="inline"> 123 <input type="hidden" name="ID" value="@Pageview.ID"> 124 <input type="hidden" name="CurrentPageID" value="@pageId"> 125 <input type="hidden" name="GroupID" value="@groupId"> 126 <input type="hidden" name="ProductID" value="@productId"> 127 <input type="hidden" name="VariantID" value="@variantId"> 128 129 <div class="form-floating"> 130 <select name="CountryCode" id="CountryCodeSelect" class="form-select d-col-12" aria-label="@Translate("Select country")" onchange="swift.PageUpdater.Update(event)"> 131 @foreach (var country in ecomCountries) 132 { 133 var selectedCountry = country.Code2 == Dynamicweb.Ecommerce.Common.Context.Country.Code2 ? "selected" : ""; 134 135 if (!string.IsNullOrEmpty(country.Name)) { 136 <option value="@country.Code2" @selectedCountry>@country.Name</option> 137 } 138 } 139 </select> 140 <label for="CountryCodeSelect">@Translate("Delivery country")</label> 141 </div> 142 </form> 143 } 144 145 @if (currencies.Count() > 1 && Model.Item.GetBoolean("CurrencySelector")) 146 { 147 <form action="/Default.aspx" data-response-target-element="PreferencesModalContent" data-layout-template="Swift_Preferences.cshtml" data-preloader="inline"> 148 <input type="hidden" name="ID" value="@Pageview.ID"> 149 <input type="hidden" name="CurrentPageID" value="@pageId"> 150 <input type="hidden" name="GroupID" value="@groupId"> 151 <input type="hidden" name="ProductID" value="@productId"> 152 <input type="hidden" name="VariantID" value="@variantId"> 153 154 <div class="form-floating"> 155 <select name="CurrencyCode" id="CurrencySelect" class="form-select d-col-12" aria-label="@Translate("Select currency")" onchange="swift.PageUpdater.Update(event)"> 156 @foreach (var currency in currencies) 157 { 158 string selectedCurrency = currency.Code == Dynamicweb.Ecommerce.Common.Context.Currency.Code ? "selected" : ""; 159 160 if (!string.IsNullOrEmpty(currency.Code)) { 161 <option value="@currency.Code" @selectedCurrency>@currency.Code</option> 162 } 163 } 164 </select> 165 <label for="CurrencySelect">@Translate("Currency")</label> 166 </div> 167 </form> 168 } 169 </div> 170 <div class="modal-footer"> 171 @{ 172 hostName = !string.IsNullOrEmpty(Pageview.Area.DomainLock) ? Pageview.Area.DomainLock : url.Host; 173 string link = $"Default.aspx?ID={updatePageId}"; 174 link += groupId != "" ? $"&GroupID={groupId}" : ""; 175 link += productId != "" ? $"&ProductID={productId}" : ""; 176 link += variantId != "" ? $"&VariantID={variantId}" : ""; 177 var friendlyUrl = $"{url.Scheme}://{hostName}{Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(link)}"; 178 } 179 180 <a href="@friendlyUrl" class="btn btn-primary w-100">@Translate("Update preferences")</a> 181 </div> 182 </div> 183 } 184 185 @* Dropdowns *@ 186 187 @if (layout == "dropdown" && type == "country") { 188 foreach (var country in ecomCountries) 189 { 190 var link = $"{url.Scheme}://{hostName}?ID={currentPage.ID}&AreaID={Pageview.Area.ID}&CountryCode={country.Code2}"; 191 link += groupId != "" ? $"&GroupID={groupId}" : ""; 192 link += productId != "" ? $"&ProductID={productId}" : ""; 193 link += variantId != "" ? $"&VariantID={variantId}" : ""; 194 195 if (!string.IsNullOrEmpty(country.Name)) { 196 <li> 197 <a href="@link" class="dropdown-item nav-link-underline @linkFontSize @linkFontWeight @linkCasing">@country.Name</a> 198 </li> 199 } 200 } 201 } 202 203 @if (layout == "dropdown" && type == "language") { 204 string iconFolder = "/Files/FlagIcons/"; 205 int languagesCount = 0; 206 207 foreach (var language in languages) 208 { 209 if (language.Area != null) { 210 if (language != null && language.Published && language.Area.Active && language.Area.Published && language.Area.ID != Dynamicweb.Frontend.PageView.Current().AreaID) { 211 hostName = !string.IsNullOrEmpty(language.Area.DomainLock) ? language.Area.DomainLock : url.Host; 212 string link = $"Default.aspx?ID={language.ID}"; 213 link += groupId != "" ? $"&GroupID={groupId}" : ""; 214 link += productId != "" ? $"&ProductID={productId}" : ""; 215 link += variantId != "" ? $"&VariantID={variantId}" : ""; 216 217 var friendlyUrl = $"{url.Scheme}://{hostName}{Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(link)}"; 218 219 string icon = iconFolder + language.Area.CultureInfo.Name.ToLower() + ".svg"; 220 <li> 221 <a hreflang="@language.Area.CultureInfo.TwoLetterISOLanguageName" href="@friendlyUrl" class="dropdown-item nav-link-underline @linkFontSize @linkFontWeight @linkCasing"><text>@{RenderIcon(icon, "icon-2");}</text> <span class="align-middle">@language.Area.DisplayName</span></a> 222 </li> 223 224 languagesCount++; 225 } 226 } 227 } 228 229 if (languagesCount == 0) { 230 <li> 231 <span class="dropdown-item fs-7 fw-normal"> 232 @Translate("Page is not translated") 233 </span> 234 </li> 235 } 236 } 237 238 @if (layout == "dropdown" && type == "currency") { 239 foreach (var currency in currencies) 240 { 241 var link = $"{url.Scheme}://{hostName}?ID={currentPage.ID}&AreaID={Pageview.Area.ID}&CurrencyCode={currency.Code}"; 242 link += groupId != "" ? $"&GroupID={groupId}" : ""; 243 link += productId != "" ? $"&ProductID={productId}" : ""; 244 link += variantId != "" ? $"&VariantID={variantId}" : ""; 245 246 <li> 247 <a href="@link" class="dropdown-item nav-link-underline @linkFontSize @linkFontWeight @linkCasing">@currency.Code</a> 248 </li> 249 } 250 } 251 252 @functions { 253 void RenderIcon(string icon, string iconSize) 254 { 255 if (Path.GetExtension(icon).ToLower() == ".svg" && !icon.ToLower().Contains("none")) 256 { 257 string iconPath = Dynamicweb.Context.Current.Server.MapPath(icon); 258 259 <span class="@iconSize"> 260 @ReadFile(iconPath) 261 </span> 262 } 263 } 264 } 265 266