Articole

Error executing template "Designs/TTonline/QueryPublisher/Autori.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_690fd3b6a56249ca9481ca7508d3c684.Execute() in Z:\Sites\_dotFusion\www.ttonline.ro\Files\Templates\Designs\TTonline\QueryPublisher\Autori.cshtml:line 337
   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 RazorTemplateBase<RazorTemplateModel<Template>> 2 @using Dynamicweb.Rendering 3 @using Dynamicweb.Content 4 @using System.Linq; 5 @using System.Web; 6 7 @functions { 8 9 //public class Session 10 //{ 11 //public string Id; 12 //public string Title; 13 //public DateTime StartTime; 14 //public DateTime EndTime; 15 //public bool IsBreak; 16 //public string Description; 17 //public string Type; 18 //public string Url; 19 //public string AllowedGroups; 20 //public string Location; 21 //public string Level; 22 //public int NumberOfSeats; 23 //public int NumberOfReservedSeats; 24 //public List<Speaker> 25 //Speakers; 26 //public List<Speaker> 27 //Moderatori; 28 //public LoopItem Item; 29 //} 30 31 public class Autor 32 { 33 public string Id; 34 public string Name; 35 public string Link; 36 public string Description; 37 public string Image; 38 public string Persoana; 39 } 40 41 public class Companie 42 { 43 public string Id; 44 public string Name; 45 public string Link; 46 public string Logo; 47 } 48 49 public class RelevantaGeografica 50 { 51 public string Id; 52 public string Name; 53 public string Link; 54 } 55 56 public class Tag 57 { 58 public string Id; 59 public string Name; 60 public string Link; 61 } 62 63 public class Sectiune 64 { 65 public string Id; 66 public string Name; 67 public string Link; 68 } 69 70 public class Editie 71 { 72 public string Id; 73 public string Name; 74 public string Link; 75 } 76 77 78 79 public static string StripHtmlTagByCharArray(string htmlString) 80 { 81 char[] array = new char[htmlString.Length]; 82 int arrayIndex = 0; 83 bool inside = false; 84 85 for (int i = 0; i < htmlString.Length; i++) 86 { 87 char let = htmlString[i]; 88 if (let == '<') 89 { 90 inside = true; 91 continue; 92 } 93 if (let == '>') 94 { 95 inside = false; 96 continue; 97 } 98 if (!inside) 99 { 100 array[arrayIndex] = let; 101 arrayIndex++; 102 } 103 } 104 return new string(array, 0, arrayIndex); 105 } 106 107 108 private List<Autor> GetAutori(string autoriList) 109 { 110 var autori = new List<Autor> (); 111 112 if(!string.IsNullOrEmpty(autoriList)){ 113 string[] itemIdList = autoriList.Split(','); 114 foreach (string itemId in itemIdList) 115 { 116 var autor = Dynamicweb.Content.Items.Item.GetItemById("Taxonomie_Autori", itemId); 117 if (autor != null) 118 { 119 autori.Add(new Autor 120 { 121 Id = itemId, 122 Name = autor["Name"] != null ? autor["Name"].ToString() : "", 123 Image = autor["Image"] != null ? autor["Image"].ToString() : "", 124 Description = autor["Description"] != null ? autor["Description"].ToString() : "", 125 Link = "/Default.aspx?ID=4250&autor="+itemId, 126 Persoana = autor["Persoana_Companie"] != null ? autor["Persoana_Companie"].ToString() : "" 127 }); 128 } 129 } 130 } 131 132 return autori; 133 } 134 135 private List<RelevantaGeografica> GetRelevanta(string relevantaList) 136 { 137 var relevante = new List<RelevantaGeografica> (); 138 139 if(!string.IsNullOrEmpty(relevantaList)){ 140 string[] itemIdList = relevantaList.Split(','); 141 foreach (string itemId in itemIdList) 142 { 143 var relevanta = Dynamicweb.Content.Items.Item.GetItemById("RelevantaGeografica", itemId); 144 if (relevanta != null) 145 { 146 relevante.Add(new RelevantaGeografica 147 { 148 Id = itemId, 149 Name = relevanta["Name"] != null ? relevanta["Name"].ToString() : "", 150 Link = "" 151 }); 152 } 153 } 154 } 155 156 return relevante; 157 } 158 159 160 private List<Sectiune> GetSectiuni(string sectiuniList) 161 { 162 var sectiuni = new List<Sectiune> (); 163 164 return sectiuni; 165 166 } 167 168 private List<Tag> GetTaguri(string taguriList) 169 { 170 var taguri = new List<Tag>(); 171 if(!string.IsNullOrEmpty(taguriList)){ 172 string[] itemIdList = taguriList.Split(','); 173 foreach (string itemId in itemIdList) 174 { 175 var tag = Dynamicweb.Content.Items.Item.GetItemById("Taxonomie_Taguri", itemId); 176 if (tag != null) 177 { 178 taguri.Add(new Tag 179 { 180 Id = itemId, 181 Name = tag["Name"] != null ? tag["Name"].ToString() : "", 182 Link = "Default.aspx?ID=4252&tag="+itemId 183 }); 184 } 185 } 186 } 187 return taguri; 188 189 } 190 191 192 private List<Companie> GetCompany(string companyList) 193 { 194 var companies = new List<Companie> (); 195 if(!string.IsNullOrEmpty(companyList)){ 196 string[] itemIdList = companyList.Split(','); 197 foreach (string itemId in itemIdList) 198 { 199 var companie = Dynamicweb.Content.Items.Item.GetItemById("Taxonomie_Companii", itemId); 200 if (companie != null) 201 { 202 companies.Add(new Companie 203 { 204 Id = itemId, 205 Name = companie["Name"] != null ? companie["Name"].ToString() : "", 206 Logo = companie["Logo"] != null ? companie["Logo"].ToString() : "", 207 Link = "/Default.aspx?ID=4271&companie="+itemId 208 }); 209 } 210 } 211 } 212 return companies; 213 214 } 215 216 217 218 } 219 220 @using Dna.ImageProcessor; 221 @using Dynamicweb.Frontend.Devices; 222 223 @{ 224 string designName = GetString("Template:DesignBaseUrl").Replace("/Files/Templates/Designs/", "").Replace("/", ""); 225 } 226 227 @functions{ 228 /// <summary> 229 /// Returns the URL for the given ImageSettings. 230 /// </summary> 231 /// <param name="settings">The ImageSettings used to generate the URL.</param> 232 private static string GetImage(ImageSettings settings) 233 { 234 return settings.ToUrl(); 235 } 236 237 /// <summary> 238 /// Returns the URL for the given ImageSettings. 239 /// </summary> 240 /// <param name="url">The URL to the image.</param> 241 /// <param name="settings">The ImageSettings used to generate the URL.</param> 242 public static string GetImage(string url, ImageSettings settings = null) 243 { 244 if (settings == null) 245 { 246 settings = new ImageSettings(); 247 } 248 settings.ImageUrl = url; 249 return GetImage(settings); 250 } 251 252 /// <summary> 253 /// Returns the URL for the given ImageSettings. 254 /// </summary> 255 /// <param name="url">The URL to the image.</param> 256 /// <param name="width">The requested width of the image.</param> 257 /// <param name="height">The requested height of the image.</param> 258 /// <param name="settings">The ImageSettings used to generate the URL.</param> 259 public static string GetImage(string url, int width, int height, ImageSettings settings = null) 260 { 261 if (settings == null) 262 { 263 settings = new ImageSettings(); 264 } 265 settings.Width = width; 266 settings.Height = height; 267 return GetImage(url, settings); 268 } 269 270 /// <summary> 271 /// Returns the URL for the given ImageSettings. 272 /// </summary> 273 /// <param name="url">The URL to the image.</param> 274 /// <param name="width">The requested width of the image.</param> 275 /// <param name="height">The requested height of the image.</param> 276 /// <param name="widthTablet">The requested width of the image for a tablet device.</param> 277 /// <param name="heightTablet">The requested height of the image for a tablet device.</param> 278 /// <param name="widthMobile">The requested width of the image for a mobile device.</param> 279 /// <param name="heightMobile">The requested height of the image for a mobile device.</param> 280 /// <param name="settings">The ImageSettings used to generate the URL.</param> 281 public static string GetImage(string url, int width, int height, int widthTablet, int heightTablet, int widthMobile, int heightMobile, ImageSettings settings = null) 282 { 283 var currentDevice = Dynamicweb.Frontend.PageView.Current().Device; 284 285 switch (currentDevice) 286 { 287 case DeviceType.Tablet: 288 width = widthTablet != 0 ? widthTablet : width; 289 height = heightTablet != 0 ? heightTablet : height; 290 break; 291 case DeviceType.Mobile: 292 width = widthMobile != 0 ? widthMobile : width; 293 height = heightMobile != 0 ? heightMobile : height; 294 break; 295 // default: Skip; just use existing width and height 296 } 297 if (settings == null) 298 { 299 settings = new ImageSettings(); 300 } 301 settings.ImageUrl = url; 302 settings.Width = width; 303 settings.Height = height; 304 return GetImage(settings); 305 } 306 } 307 308 @{ 309 string activeURL = "PageNum=" + GetString("DwPaging.CurrentPage"); 310 string numarPagina = System.Web.HttpContext.Current.Request.Params["PageNum"]; 311 } 312 313 <div class="row"> 314 315 @foreach (var result in GetLoop("QueryResultItem")) { 316 317 string title = result.GetString("Dw_Page_Titlu"); 318 string description = result.GetString("Dw_Page_Sumar"); 319 string url = result.GetString("ItemPublisher:Item.Url"); 320 321 string imageRaw = result.GetString("Dw_Page_ImaginePrincipala"); 322 string image = !string.IsNullOrEmpty(imageRaw) ? GetImage(imageRaw, 240, 155) + "&bgcolor=white" : "/Files/Images/NoImage/240x155.png"; 323 324 325 326 string sectiune = result.GetString("Dw_Page_SectiuneParinte"); 327 string sectiuneID = result.GetString("Dw_Page_SectiuneParinteId"); 328 string pageID = result.GetString("PageId"); 329 string link = "Default.aspx?ID="+pageID; 330 string sectionLink = "Default.aspx?ID="+sectiuneID; 331 string sectionClass= "bg"+@sectiuneID; 332 DateTime date = result.GetDate("Dw_Page_Data"); 333 string data = date.ToString("dd MMMM yyyy"); 334 string pageLink = GetString("DwPaging.FirstPageLink"); 335 string queryAutor = HttpContext.Current.Request.QueryString["autor"]; 336 var autori = GetAutori(queryAutor); 337 var numeAutor = autori.FirstOrDefault().Name; 338 339 340 341 <article class="simple-post simple-big clearfix col-md-12 separator-articole media"> 342 <div class="simple-thumb media-left media-top" style="width: 265px;"> 343 <a href="@link"> 344 <figure class="image-overlay"> 345 <img src="@image"> 346 </figure> 347 </a> 348 </div> 349 350 <header class="media-body"> 351 <p class="simple-share" style="color: #bbbbbb; font-weight: 400;"> 352 <a href="@sectionLink" class="link-autor" style="color: #999999 !important; font-weight: 400 !important;">@sectiune</a> 353 <span style="margin: 0;">/</span> 354 @Translate("articolde","de") 355 <a href="@pageLink" class="link-autor" style="color: #999999 !important; font-weight: 400 !important;">@numeAutor</a> 356 <span>- <i class="fa fa-clock-o"></i> @data</span> 357 </p> 358 359 <h3> 360 <a href="@link">@title</a> 361 </h3> 362 363 @description 364 </header> 365 </article> 366 367 368 } 369 </div> 370 371 372 373 374 375 @if(GetInteger("DwPaging.PageCount") >1) 376 { 377 <nav> 378 <ul class="pagination pagination-sm"> 379 380 381 @if(GetInteger("DwPaging.CurrentPage") >1) 382 { 383 <li> 384 385 <a style="margin-right: 0.2em" href="@GetValue("DwPaging.FirstPageLink")">« </a> 386 <a href='@GetValue("DwPaging.PreviousPageLink")' aria-label='@Translate("paginaAnterioara", "Pagina anterioara")'><span aria-hidden="true"><i class="fa fa-angle-left"></i></span></a> 387 388 389 </li> 390 } 391 392 @foreach (LoopItem i in GetLoop("DwPaging.LoopPageGroup")) { 393 394 if(GetBoolean("PageGroup.PageNumber")) { 395 <li class="active">@i.GetValue("PageGroup.PageNumber")</li> 396 } else { 397 <li><a href='@i.GetValue("PageGroup.PageLink")'>@i.GetValue("PageGroup.PageNumber")</a></li> 398 } 399 400 401 } 402 403 @if(GetInteger("DwPaging.PageCount") > GetInteger("DwPaging.CurrentPage")) 404 { 405 <li> 406 <a href='@GetValue("DwPaging.NextPageLink")' aria-label='@Translate("paginaUrmatoare", "Pagina urmatoare")'><span aria-hidden="true"><i class="fa fa-angle-right"></i></span></a> 407 <a href='@GetValue("DwPaging.LastPageLink")'>» </a> 408 </li> 409 } 410 411 412 413 414 415 </ul> 416 </nav> 417 } 418 419 <script> 420 421 $(function(){ 422 423 424 function getURL(url) { 425 name = url.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]').replace("&amp;" , "&").replace("&amp;" , "&"); 426 427 return name; 428 } 429 430 // get URL value 431 var query = getURL("@activeURL"); 432 var listOfLi = $("ul.pagination.pagination-sm li a"); 433 434 console.log("query" , query); 435 // if the URL does not contains 'page' , make the first li active 436 // if(query.indexOf("PageNum") != 0) { 437 // $("ul.pagination.pagination-sm li:first").addClass("active"); 438 // } 439 440 441 // remove PID=153 from each li url 442 $.each(listOfLi , function(index , element){ 443 var replacement = $(element).attr("href").replace("&PID=153" , ""); 444 $(element).attr("href" , replacement); 445 }); 446 447 448 var firstTimeOnPage = _.includes(query , "PageNum"); 449 450 if(!firstTimeOnPage) { 451 $("ul.pagination.pagination-sm li:first").addClass("active"); 452 } 453 454 455 456 // check if URL value is equal to any of li's URL value 457 _.map(listOfLi , function(obj){ 458 459 var liURL = $(obj).attr("href").replace("/" , "").replace("&PID=153" , ""); 460 var included = _.includes(liURL , query); 461 462 if(included) { 463 $(obj).parent().addClass("active"); 464 } 465 466 }); 467 468 }); 469 470 471 </script> 472 473 <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
Profil companie

Accept cookie

www.ttonline.ro utilizează fişiere de tip cookie pentru a personaliza și îmbunătăți experiența ta pe Website-ul nostru.

Te informăm că ne-am actualizat politicile pentru a integra în acestea și în activitatea curentă a www.ttonline.ro cele mai recente modificări propuse de Regulamentul (UE) 2016/679 privind protecția persoanelor fizice în ceea ce privește prelucrarea datelor cu caracter personal și privind libera
circulație a acestor date. Înainte de a continua navigarea pe Website-ul nostru, te rugăm să aloci timpul necesar pentru a citi și înțelege conținutul Politicii de Cookie.

Prin continuarea navigării pe Website-ul nostru confirmi acceptarea utilizării fişierelor de tip cookie conform Politicii de Cookie. Îți mulțumim pentru acest accept și nu uita totuși că poți modifica în orice moment setările acestor fişiere cookie urmând instrucțiunile din Politica de Cookie.