public string GetNodeHtml(IPublishedContent content) { var htmlString = ""; if (content != null) { if (content.TemplateId > 0) { var htmlObject = _umbracoHelper.RenderTemplate(content.Id); htmlString = htmlObject.ToHtmlString(); } } return(htmlString); }
public PageInformation GetpageInformation(int id) { var pageInformation = new PageInformation(); var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); var content = umbracoHelper.TypedContent(id); var htmlObject = umbracoHelper.RenderTemplate(id); var html = htmlObject.ToHtmlString(); var htmlParser = new HtmlDocument(); htmlParser.LoadHtml(HttpUtility.HtmlDecode(html)); var headTag = htmlParser.DocumentNode.GetElements("head"); if (headTag.Any()) { var titleTags = headTag.First().GetElements("title"); if (titleTags.Any()) { pageInformation.Title = titleTags.First().InnerText; } } var metaTags = htmlParser.DocumentNode.GetElements("meta"); var attributeValues = from metaTag in metaTags let attribute = metaTag.GetAttribute("name") where attribute != null where attribute.Value == "description" select metaTag.GetAttribute("content"); if (attributeValues.Any()) { pageInformation.Description = attributeValues.First().Value; } pageInformation.Url = content.UrlWithDomain(); return(pageInformation); }
public string GetNodeHtml(IPublishedContent content) { if (content == null) { throw new ArgumentNullException("content", "Content parameter cannot be null"); } if (content.Id == 0) { throw new MissingFieldException("The Id of content is not set"); } if (content.TemplateId == 0) { throw new MissingFieldException("The templateId of content is not set"); } var htmlObject = _umbracoHelper.RenderTemplate(content.Id); return(htmlObject != null?htmlObject.ToHtmlString() : null); }
public static void SendFormData(this UmbracoHelper context, object form, bool saveMessage = true, bool showCcList = false, IEnumerable <IPublishedContent> attachments = null) { Dictionary <object, object> contextItems = getCurrentContextItems(); HttpContext Context = HttpContext.Current; ISubmitDetails details = form as ISubmitDetails; IConfirmationDetails confirm = form as IConfirmationDetails; try { if (!string.IsNullOrEmpty(details.FieldPattern)) { if (details.FieldPattern.Contains("{0}")) { Refactored.Email.Email.FieldPattern = details.FieldPattern; } else { Refactored.Email.Email.FieldDelimiters = details.FieldPattern; } } else { Refactored.Email.Email.FieldDelimiters = "[]"; } if (details != null && details.HtmlTemplateId > 0 && details.TextTemplateId > 0) { string subject = string.Empty; string htmlBody = string.Empty; string textBody = string.Empty; if (details.HtmlTemplateId > 0) { htmlBody = Refactored.Email.Email.ParseMessageTemplateContent( context.RenderTemplate(details.HtmlTemplateId).ToString(), form, out subject); } if (details.TextTemplateId > 0) { textBody = Refactored.Email.Email.ParseMessageTemplateContent( context.RenderTemplate(details.TextTemplateId).ToString(), form); if (string.IsNullOrEmpty(subject)) { subject = new Node(details.TextTemplateId).Name; } } SendEmail(details.FromEmail, details.ToEmail, subject, htmlBody, textBody, bcc: showCcList?null: details.BccEmail, cc: showCcList ? details.BccEmail : null, attachments: attachments); if (saveMessage) { MessageManager.CreateMessage(confirm == null ? details.FromEmail : confirm.SubmitterEmail, details.ToEmail, subject, htmlBody, textBody); } } if (confirm != null && (confirm.HtmlConfirmationTemplateId > 0 || confirm.TextConfirmationTemplateId > 0)) { string htmlBody = string.Empty; string textBody = string.Empty; string subject = string.Empty; if (confirm.HtmlConfirmationTemplateId > 0) { htmlBody = Refactored.Email.Email.ParseMessageTemplateContent( context.RenderTemplate(confirm.HtmlConfirmationTemplateId).ToString(), form, out subject); } if (confirm.TextConfirmationTemplateId > 0) { textBody = Refactored.Email.Email.ParseMessageTemplateContent( context.RenderTemplate(confirm.TextConfirmationTemplateId).ToString(), form); if (string.IsNullOrEmpty(subject)) { subject = new Node(confirm.TextConfirmationTemplateId).Name; } } SendEmail(confirm.FromEmail, confirm.SubmitterEmail, subject, htmlBody, textBody, attachments: attachments); } } finally { updateLocalContextItems(contextItems, Context); } }
public string GenerateItemHtml(int id) { return(helper.RenderTemplate(id).ToString()); }
public virtual string GenerateItemHtml(UmbracoHelper umbracoHelper, int itemId) => umbracoHelper.RenderTemplate(itemId, new int?()).ToString();