Articole

Exception in template (Designs\TTonline\QueryPublisher/Autori.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.cfcdcebadcaaac.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits RazorTemplateBase<RazorTemplateModel<Template>> @using Dynamicweb.Rendering @using Dynamicweb.Content @using System.Linq; @using System.Web; @functions { //public class Session //{ //public string Id; //public string Title; //public DateTime StartTime; //public DateTime EndTime; //public bool IsBreak; //public string Description; //public string Type; //public string Url; //public string AllowedGroups; //public string Location; //public string Level; //public int NumberOfSeats; //public int NumberOfReservedSeats; //public List<Speaker> //Speakers; //public List<Speaker> //Moderatori; //public LoopItem Item; //} public class Autor { public string Id; public string Name; public string Link; public string Description; public string Image; public string Persoana; } public class Companie { public string Id; public string Name; public string Link; public string Logo; } public class RelevantaGeografica { public string Id; public string Name; public string Link; } public class Tag { public string Id; public string Name; public string Link; } public class Sectiune { public string Id; public string Name; public string Link; } public class Editie { public string Id; public string Name; public string Link; } public static string StripHtmlTagByCharArray(string htmlString) { char[] array = new char[htmlString.Length]; int arrayIndex = 0; bool inside = false; for (int i = 0; i < htmlString.Length; i++) { char let = htmlString[i]; if (let == '<') { inside = true; continue; } if (let == '>') { inside = false; continue; } if (!inside) { array[arrayIndex] = let; arrayIndex++; } } return new string(array, 0, arrayIndex); } private List<Autor> GetAutori(string autoriList) { var autori = new List<Autor> (); if(!string.IsNullOrEmpty(autoriList)){ string[] itemIdList = autoriList.Split(','); foreach (string itemId in itemIdList) { var autor = Dynamicweb.Content.Items.Item.GetItemById("Taxonomie_Autori", itemId); if (autor != null) { autori.Add(new Autor { Id = itemId, Name = autor["Name"] != null ? autor["Name"].ToString() : "", Image = autor["Image"] != null ? autor["Image"].ToString() : "", Description = autor["Description"] != null ? autor["Description"].ToString() : "", Link = "/Default.aspx?ID=4250&autor="+itemId, Persoana = autor["Persoana_Companie"] != null ? autor["Persoana_Companie"].ToString() : "" }); } } } return autori; } private List<RelevantaGeografica> GetRelevanta(string relevantaList) { var relevante = new List<RelevantaGeografica> (); if(!string.IsNullOrEmpty(relevantaList)){ string[] itemIdList = relevantaList.Split(','); foreach (string itemId in itemIdList) { var relevanta = Dynamicweb.Content.Items.Item.GetItemById("RelevantaGeografica", itemId); if (relevanta != null) { relevante.Add(new RelevantaGeografica { Id = itemId, Name = relevanta["Name"] != null ? relevanta["Name"].ToString() : "", Link = "" }); } } } return relevante; } private List<Sectiune> GetSectiuni(string sectiuniList) { var sectiuni = new List<Sectiune> (); return sectiuni; } private List<Tag> GetTaguri(string taguriList) { var taguri = new List<Tag>(); if(!string.IsNullOrEmpty(taguriList)){ string[] itemIdList = taguriList.Split(','); foreach (string itemId in itemIdList) { var tag = Dynamicweb.Content.Items.Item.GetItemById("Taxonomie_Taguri", itemId); if (tag != null) { taguri.Add(new Tag { Id = itemId, Name = tag["Name"] != null ? tag["Name"].ToString() : "", Link = "Default.aspx?ID=4252&tag="+itemId }); } } } return taguri; } private List<Companie> GetCompany(string companyList) { var companies = new List<Companie> (); if(!string.IsNullOrEmpty(companyList)){ string[] itemIdList = companyList.Split(','); foreach (string itemId in itemIdList) { var companie = Dynamicweb.Content.Items.Item.GetItemById("Taxonomie_Companii", itemId); if (companie != null) { companies.Add(new Companie { Id = itemId, Name = companie["Name"] != null ? companie["Name"].ToString() : "", Logo = companie["Logo"] != null ? companie["Logo"].ToString() : "", Link = "/Default.aspx?ID=4271&companie="+itemId }); } } } return companies; } } @using Dna.ImageProcessor; @using Dynamicweb.Frontend.Devices; @{ string designName = GetString("Template:DesignBaseUrl").Replace("/Files/Templates/Designs/", "").Replace("/", ""); } @functions{ /// <summary> /// Returns the URL for the given ImageSettings. /// </summary> /// <param name="settings">The ImageSettings used to generate the URL.</param> private static string GetImage(ImageSettings settings) { return settings.ToUrl(); } /// <summary> /// Returns the URL for the given ImageSettings. /// </summary> /// <param name="url">The URL to the image.</param> /// <param name="settings">The ImageSettings used to generate the URL.</param> public static string GetImage(string url, ImageSettings settings = null) { if (settings == null) { settings = new ImageSettings(); } settings.ImageUrl = url; return GetImage(settings); } /// <summary> /// Returns the URL for the given ImageSettings. /// </summary> /// <param name="url">The URL to the image.</param> /// <param name="width">The requested width of the image.</param> /// <param name="height">The requested height of the image.</param> /// <param name="settings">The ImageSettings used to generate the URL.</param> public static string GetImage(string url, int width, int height, ImageSettings settings = null) { if (settings == null) { settings = new ImageSettings(); } settings.Width = width; settings.Height = height; return GetImage(url, settings); } /// <summary> /// Returns the URL for the given ImageSettings. /// </summary> /// <param name="url">The URL to the image.</param> /// <param name="width">The requested width of the image.</param> /// <param name="height">The requested height of the image.</param> /// <param name="widthTablet">The requested width of the image for a tablet device.</param> /// <param name="heightTablet">The requested height of the image for a tablet device.</param> /// <param name="widthMobile">The requested width of the image for a mobile device.</param> /// <param name="heightMobile">The requested height of the image for a mobile device.</param> /// <param name="settings">The ImageSettings used to generate the URL.</param> public static string GetImage(string url, int width, int height, int widthTablet, int heightTablet, int widthMobile, int heightMobile, ImageSettings settings = null) { var currentDevice = Dynamicweb.Frontend.PageView.Current().Device; switch (currentDevice) { case DeviceType.Tablet: width = widthTablet != 0 ? widthTablet : width; height = heightTablet != 0 ? heightTablet : height; break; case DeviceType.Mobile: width = widthMobile != 0 ? widthMobile : width; height = heightMobile != 0 ? heightMobile : height; break; // default: Skip; just use existing width and height } if (settings == null) { settings = new ImageSettings(); } settings.ImageUrl = url; settings.Width = width; settings.Height = height; return GetImage(settings); } } @{ string activeURL = "PageNum=" + GetString("DwPaging.CurrentPage"); string numarPagina = System.Web.HttpContext.Current.Request.Params["PageNum"]; } <div class="row"> @foreach (var result in GetLoop("QueryResultItem")) { string title = result.GetString("Dw_Page_Titlu"); string description = result.GetString("Dw_Page_Sumar"); string url = result.GetString("ItemPublisher:Item.Url"); string imageRaw = result.GetString("Dw_Page_ImaginePrincipala"); string image = !string.IsNullOrEmpty(imageRaw) ? GetImage(imageRaw, 240, 155) + "&bgcolor=white" : "/Files/Images/NoImage/240x155.png"; string sectiune = result.GetString("Dw_Page_SectiuneParinte"); string sectiuneID = result.GetString("Dw_Page_SectiuneParinteId"); string pageID = result.GetString("PageId"); string link = "Default.aspx?ID="+pageID; string sectionLink = "Default.aspx?ID="+sectiuneID; string sectionClass= "bg"+@sectiuneID; DateTime date = result.GetDate("Dw_Page_Data"); string data = date.ToString("dd MMMM yyyy"); string pageLink = GetString("DwPaging.FirstPageLink"); string queryAutor = HttpContext.Current.Request.QueryString["autor"]; var autori = GetAutori(queryAutor); var numeAutor = autori.FirstOrDefault().Name; <article class="simple-post simple-big clearfix col-md-12 separator-articole media"> <div class="simple-thumb media-left media-top" style="width: 265px;"> <a href="@link"> <figure class="image-overlay"> <img src="@image"> </figure> </a> </div> <header class="media-body"> <p class="simple-share" style="color: #bbbbbb; font-weight: 400;"> <a href="@sectionLink" class="link-autor" style="color: #999999 !important; font-weight: 400 !important;">@sectiune</a> <span style="margin: 0;">/</span> @Translate("articolde","de") <a href="@pageLink" class="link-autor" style="color: #999999 !important; font-weight: 400 !important;">@numeAutor</a> <span>- <i class="fa fa-clock-o"></i> @data</span> </p> <h3> <a href="@link">@title</a> </h3> @description </header> </article> } </div> @if(GetInteger("DwPaging.PageCount") >1) { <nav> <ul class="pagination pagination-sm"> @if(GetInteger("DwPaging.CurrentPage") >1) { <li> <a style="margin-right: 0.2em" href="@GetValue("DwPaging.FirstPageLink")">« </a> <a href='@GetValue("DwPaging.PreviousPageLink")' aria-label='@Translate("paginaAnterioara", "Pagina anterioara")'><span aria-hidden="true"><i class="fa fa-angle-left"></i></span></a> </li> } @foreach (LoopItem i in GetLoop("DwPaging.LoopPageGroup")) { if(GetBoolean("PageGroup.PageNumber")) { <li class="active">@i.GetValue("PageGroup.PageNumber")</li> } else { <li><a href='@i.GetValue("PageGroup.PageLink")'>@i.GetValue("PageGroup.PageNumber")</a></li> } } @if(GetInteger("DwPaging.PageCount") > GetInteger("DwPaging.CurrentPage")) { <li> <a href='@GetValue("DwPaging.NextPageLink")' aria-label='@Translate("paginaUrmatoare", "Pagina urmatoare")'><span aria-hidden="true"><i class="fa fa-angle-right"></i></span></a> <a href='@GetValue("DwPaging.LastPageLink")'>» </a> </li> } </ul> </nav> } <script> $(function(){ function getURL(url) { name = url.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]').replace("&amp;" , "&").replace("&amp;" , "&"); return name; } // get URL value var query = getURL("@activeURL"); var listOfLi = $("ul.pagination.pagination-sm li a"); console.log("query" , query); // if the URL does not contains 'page' , make the first li active // if(query.indexOf("PageNum") != 0) { // $("ul.pagination.pagination-sm li:first").addClass("active"); // } // remove PID=153 from each li url $.each(listOfLi , function(index , element){ var replacement = $(element).attr("href").replace("&PID=153" , ""); $(element).attr("href" , replacement); }); var firstTimeOnPage = _.includes(query , "PageNum"); if(!firstTimeOnPage) { $("ul.pagination.pagination-sm li:first").addClass("active"); } // check if URL value is equal to any of li's URL value _.map(listOfLi , function(obj){ var liURL = $(obj).attr("href").replace("/" , "").replace("&PID=153" , ""); var included = _.includes(liURL , query); if(included) { $(obj).parent().addClass("active"); } }); }); </script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>

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.

Da, sunt de acord