public TemplateDefinition GetTemplate(N2.ContentItem item) { var httpContext = httpContextProvider.Get(); if (httpContext != null) { if (N2.Web.Mvc.Html.RegistrationExtensions.GetRegistrationExpression(httpContext) != null) { return(null); } } string templateKey = item.TemplateKey; if (templateKey == null) { return(null); } return(GetTemplates(item.GetContentType()).Where(t => t.Name == templateKey).Select(t => { t.OriginalFactory = t.TemplateFactory; t.TemplateFactory = () => item; return t; }).FirstOrDefault()); }
public TemplateDefinition GetTemplate(N2.ContentItem item) { string templateName = item["TemplateName"] as string; if (templateName == null) { return(null); } return(GetTemplates(item.GetContentType()).Where(t => t.Name == templateName).Select(t => { t.Original = t.Template; t.Template = item; return t; }).FirstOrDefault()); }
protected virtual void OnWritingDefaultAttributes(N2.ContentItem item, XmlTextWriter xtw) { xtw.WriteAttributeString("id", item.ID.ToString()); xtw.WriteAttributeString("name", item.Name); xtw.WriteAttributeString("title", item.Title); xtw.WriteAttributeString("zoneName", item.ZoneName); xtw.WriteAttributeString("created", GetDateTimeString(item.Created)); xtw.WriteAttributeString("updated", GetDateTimeString(item.Updated)); xtw.WriteAttributeString("published", (item.Published.HasValue) ? GetDateTimeString(item.Published.Value) : string.Empty); xtw.WriteAttributeString("expires", (item.Expires.HasValue) ? GetDateTimeString(item.Expires.Value) : string.Empty); xtw.WriteAttributeString("sortOrder", item.SortOrder.ToString()); xtw.WriteAttributeString("url", engine.UrlParser.BuildUrl(item)); xtw.WriteAttributeString("visible", item.Visible.ToString()); xtw.WriteAttributeString("savedBy", item.SavedBy); xtw.WriteAttributeString("typeName", SerializationUtility.GetTypeAndAssemblyName(item.GetContentType())); xtw.WriteAttributeString("discriminator", engine.Definitions.GetDefinition(item).Discriminator); }