public static SimpleTemplate FromTemplate(int templateId, bool recurse = true) { if (templateId <= 0) return null; var tpl = new template(templateId); return FromTemplate(tpl, recurse); }
public static string GetMasterPageName(int templateID, string templateFolder) { template t = (template)templateCache["template" + templateID]; if (t == null) { t = new template(templateID); } if (t != null) { if (!string.IsNullOrEmpty(templateFolder)) { return(t.AlternateMasterPageFile(templateFolder)); } else { return(t.MasterPageFile); } } else { throw new ArgumentException(String.Format("Template with id '{0}' not found", templateID)); } }
private void checkForMaster(int templateID) { // Get template design if (_masterTemplate != 0 && _masterTemplate != templateID) { template masterTemplateDesign = new template(_masterTemplate); if (masterTemplateDesign.TemplateContent.IndexOf("<?UMBRACO_TEMPLATE_LOAD_CHILD/>") > -1 || masterTemplateDesign.TemplateContent.IndexOf("<?UMBRACO_TEMPLATE_LOAD_CHILD />") > -1) { templateOutput.Append( masterTemplateDesign.TemplateContent.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD/>", _templateDesign).Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD />", _templateDesign) ); } else { templateOutput.Append(_templateDesign); } } else { if (_masterTemplate == templateID) { System.Web.HttpContext.Current.Trace.Warn("template", "Master template is the same as the current template. It would course an endless loop!"); } templateOutput.Append(_templateDesign); } }
private void checkForMaster(int templateID) { // Get template design if (_masterTemplate != 0 && _masterTemplate != templateID) { template masterTemplateDesign = new template(_masterTemplate); if (masterTemplateDesign.TemplateContent.IndexOf("<?UMBRACO_TEMPLATE_LOAD_CHILD/>") > -1 || masterTemplateDesign.TemplateContent.IndexOf("<?UMBRACO_TEMPLATE_LOAD_CHILD />") > -1) { _templateOutput.Append( masterTemplateDesign.TemplateContent.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD/>", _templateDesign).Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD />", _templateDesign) ); } else { _templateOutput.Append(_templateDesign); } } else { if (_masterTemplate == templateID) { cms.businesslogic.template.Template t = cms.businesslogic.template.Template.GetTemplate(templateID); string templateName = (t != null) ? t.Text : string.Format("'Template with id: '{0}", templateID); System.Web.HttpContext.Current.Trace.Warn("template", String.Format("Master template is the same as the current template. It would cause an endless loop! Make sure that the current template '{0}' has another Master Template than itself. You can change this in the template editor under 'Settings'", templateName)); _templateOutput.Append(_templateDesign); } } }
public static string GetMasterPageName(int templateID, string templateFolder) { var t = new template(templateID); return(!string.IsNullOrEmpty(templateFolder) ? t.AlternateMasterPageFile(templateFolder) : t.MasterPageFile); }
public void RenderPage(int templateId) { if (templateId != 0) { template templateDesign = new template(templateId); _pageContentControl = templateDesign.ParseWithControls(this); _pageContent.Append(templateDesign.TemplateContent); } }
public void RenderPage(int templateId) { if (templateId != 0) { template templateDesign = new template(templateId); HttpContext.Current.Items["umbPageObject"] = this; _pageContentControl = templateDesign.ParseWithControls(this); _pageContent.Append(templateDesign.TemplateContent); } }
public static SimpleTemplate FromTemplate(template tpl, bool recurse = true) { if (tpl == null) return null; var result = new SimpleTemplate() { Alias = tpl.TemplateAlias }; if (recurse) { result.Parent = FromTemplate(tpl.MasterTemplate); } return result; }
public template(int templateID) { if (templateCache["template" + templateID.ToString()] != null) { template t = (template)templateCache["template" + templateID]; this._masterTemplate = t._masterTemplate; this._templateAlias = t._templateAlias; this._templateDesign = t._templateDesign; this._masterTemplate = t._masterTemplate; this._templateName = t._templateName; } else { using (IRecordsReader templateData = SqlHelper.ExecuteReader("select nodeId, alias, master, text, design from cmsTemplate inner join umbracoNode node on node.id = cmsTemplate.nodeId where nodeId = @templateID", SqlHelper.CreateParameter("@templateID", templateID))) { if (templateData.Read()) { // Get template master and replace content where the template if (!templateData.IsNull("master")) { _masterTemplate = templateData.GetInt("master"); } if (!templateData.IsNull("alias")) { _templateAlias = templateData.GetString("alias"); } if (!templateData.IsNull("text")) { _templateName = templateData.GetString("text"); } if (!templateData.IsNull("design")) { _templateDesign = templateData.GetString("design"); } templateData.Close(); templateCache.Insert("template" + templateID.ToString(), this); } } } // Only check for master on legacy templates - can show error when using master pages. if (!UmbracoSettings.UseAspNetMasterPages) { checkForMaster(templateID); } }
public void RenderPage(int Template) { if (Template != 0) { HttpContext.Current.Trace.Write("umbracoPage", "Loading template (ID: " + Template + ")"); template templateDesign = new template(Template); HttpContext.Current.Trace.Write("page", "Template loaded"); HttpContext.Current.Items["umbPageObject"] = this; pageContentControl = templateDesign.ParseWithControls(this); pageContent.Append(templateDesign.TemplateContent); } else { HttpContext.Current.Trace.Warn("page.RenderPage", "No template defined (value=0)"); } }
/// <summary> /// Renders the content of a macro. Uses the normal template umbraco macro markup as input. /// This only works properly with xslt macros. /// Python and .ascx based macros will not render properly, as viewstate is not included. /// </summary> /// <param name="Text">The macro markup to be rendered.</param> /// <param name="PageId">The page id.</param> /// <returns>The rendered macro as a string</returns> public static string RenderMacroContent(string Text, int PageId) { try { page p = new page(((IHasXmlNode)GetXmlNodeById(PageId.ToString()).Current).GetNode()); template t = new template(p.Template); Control c = t.parseStringBuilder(new StringBuilder(Text), p); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); c.RenderControl(hw); return sw.ToString(); } catch (Exception ee) { return string.Format("<!-- Error generating macroContent: '{0}' -->", ee); } }
public override GridLayout GetLayout() { var document = new Document(Convert.ToInt32(_referenceId)); if (document.Template == 0) return new GridLayout(0); var template = new template(document.Template); return GridModuleService.GetPageGridLayout(template.MasterPageFile); }
private void checkForMaster(int templateID) { // Get template design if (_masterTemplate != 0 && _masterTemplate != templateID) { template masterTemplateDesign = new template(_masterTemplate); if (masterTemplateDesign.TemplateContent.IndexOf("<?UMBRACO_TEMPLATE_LOAD_CHILD/>") > -1 || masterTemplateDesign.TemplateContent.IndexOf("<?UMBRACO_TEMPLATE_LOAD_CHILD />") > -1) { _templateOutput.Append( masterTemplateDesign.TemplateContent.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD/>", _templateDesign).Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD />", _templateDesign) ); } else _templateOutput.Append(_templateDesign); } else { if (_masterTemplate == templateID) { cms.businesslogic.template.Template t = cms.businesslogic.template.Template.GetTemplate(templateID); string templateName = (t != null) ? t.Text : string.Format("'Template with id: '{0}", templateID); System.Web.HttpContext.Current.Trace.Warn("template", String.Format("Master template is the same as the current template. It would cause an endless loop! Make sure that the current template '{0}' has another Master Template than itself. You can change this in the template editor under 'Settings'", templateName)); _templateOutput.Append(_templateDesign); } } }
public static string GetMasterPageName(int templateID, string templateFolder) { var t = new template(templateID); return !string.IsNullOrEmpty(templateFolder) ? t.AlternateMasterPageFile(templateFolder) : t.MasterPageFile; }
public override GridLayout GetLayout() { var document = new Document(Convert.ToInt32(_referenceId)); if (document.Template == 0) throw new ApplicationException("Please assign a layout template to the document"); var template = new template(document.Template); return GridModuleService.GetPageGridLayout(template.MasterPageFile); }
public static string GetMasterPageName(int templateID, string templateFolder) { template t = (template)templateCache["template" + templateID]; if (t == null) t = new template(templateID); if (t != null) if (!string.IsNullOrEmpty(templateFolder)) return t.AlternateMasterPageFile(templateFolder); else return t.MasterPageFile; else throw new ArgumentException(String.Format("Template with id '{0}' not found", templateID)); }