当前位置: 首页>>代码示例>>C#>>正文


C# template.Template类代码示例

本文整理汇总了C#中umbraco.cms.businesslogic.template.Template的典型用法代码示例。如果您正苦于以下问题:C# Template类的具体用法?C# Template怎么用?C# Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Template类属于umbraco.cms.businesslogic.template命名空间,在下文中一共展示了Template类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateViewFile

        internal static string UpdateViewFile(Template t, string currentAlias = null)
        {
            var path = IOHelper.MapPath(ViewPath(t.Alias));

			if (string.IsNullOrEmpty(currentAlias) == false && currentAlias != t.Alias)
			{
				//NOTE: I don't think this is needed for MVC, this was ported over from the
				// masterpages helper but I think only relates to when templates are stored in the db.
				////Ensure that child templates have the right master masterpage file name
				//if (t.HasChildren)
				//{
				//	var c = t.Children;
				//	foreach (CMSNode cmn in c)
				//		UpdateViewFile(new Template(cmn.Id), null);
				//}

				//then kill the old file.. 
				var oldFile = IOHelper.MapPath(ViewPath(currentAlias));
				if (File.Exists(oldFile))
					File.Delete(oldFile);
			}

            File.WriteAllText(path, t.Design, Encoding.UTF8);
            return t.Design;
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:25,代码来源:ViewHelper.cs

示例2: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            templateID = int.Parse(Request["id"]);
            Template t = new Template(templateID);

            if (Skinning.StarterKitGuid(templateID).HasValue)
            {
                p_apply.Visible = true;

                string currentSkin = Skinning.GetCurrentSkinAlias(templateID);
                int templateRoot = FindTemplateRoot((CMSNode)t);

                dd_skins.Items.Add("Choose...");
                foreach (KeyValuePair<string,string> kvp in Skinning.AllowedSkins(templateRoot))
                {
                    ListItem li = new ListItem(kvp.Value, kvp.Key);
                    if (kvp.Key == currentSkin)
                        li.Selected = true;

                    dd_skins.Items.Add(li);
                }

                if (!string.IsNullOrEmpty(Skinning.GetCurrentSkinAlias(templateID)))
                {
                    ph_rollback.Visible = true;
                }
            }
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:28,代码来源:TemplateSkinning.aspx.cs

示例3: SaveTemplateToFile

 internal static string SaveTemplateToFile(Template template, string currentAlias)
 {
     var design = EnsureInheritedLayout(template);
     File.WriteAllText(IOHelper.MapPath(ViewPath(template.Alias)), design, Encoding.UTF8);
     
     return template.Design;
 }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:7,代码来源:ViewHelper.cs

示例4: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            _templateId = int.Parse(Request["id"]);
            var t = new Template(_templateId);

            if (Skinning.StarterKitGuid(_templateId).HasValue)
            {
                p_apply.Visible = true;

                var currentSkin = Skinning.GetCurrentSkinAlias(_templateId);
                var templateRoot = FindTemplateRoot(t);

                dd_skins.Items.Add("Choose...");
                foreach (var kvp in Skinning.AllowedSkins(templateRoot))
                {
                    var li = new ListItem(kvp.Value, kvp.Key);
                    if (kvp.Key == currentSkin)
                        li.Selected = true;

                    dd_skins.Items.Add(li);
                }

                if (!string.IsNullOrEmpty(Skinning.GetCurrentSkinAlias(_templateId)))
                {
                    ph_rollback.Visible = true;
                }
            }
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:28,代码来源:TemplateSkinning.aspx.cs

示例5: UpdateMasterPageFile

        internal static string UpdateMasterPageFile(Template t, string currentAlias)
        {
            var template = UpdateMasterPageContent(t, currentAlias);
            UpdateChildTemplates(t, currentAlias);
            SaveDesignToFile(t, currentAlias, template);

            return template;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:8,代码来源:MasterpageHelper.cs

示例6: delete

        public void delete(int id, string username, string password)
        {
            Authenticate(username, password);

            if (id == 0) throw new Exception("ID must be specifed when updating");

            cms.businesslogic.template.Template template = new cms.businesslogic.template.Template(id);
            template.delete();
        }
开发者ID:JianwenSun,项目名称:mono-soc-2007,代码行数:9,代码来源:TemplateService.asmx.cs

示例7: RenderTemplate

        public string RenderTemplate(int id)
        {
            const string urlPattern = "http://{0}/?altTemplate={1}";

            var t = new Template(id);
            var host = HttpContext.Current.Request.Url.Host;
            if (HttpContext.Current.Request.Url.Port != 80) host += ":" + HttpContext.Current.Request.Url.Port;

            var url = string.Format(urlPattern, host, t.Alias);
            return ReadUrl(url);
        }
开发者ID:OlivierAlbertini,项目名称:workflow-for-dot-net,代码行数:11,代码来源:Helper.cs

示例8: GetFileContents

        internal static string GetFileContents(Template t)
        {
            string masterpageContent = "";
			if (File.Exists(GetFilePath(t)))
			{
				System.IO.TextReader tr = new StreamReader(GetFilePath(t));
                masterpageContent = tr.ReadToEnd();
                tr.Close();
            }

            return masterpageContent;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:12,代码来源:MasterpageHelper.cs

示例9: GetDocPath

        private static string GetDocPath(Template item)
        {
            string path = "";
            if (item != null)
            {
                if (item.MasterTemplate != 0)
                {
                    path = GetDocPath(new Template(item.MasterTemplate));
                }

                path = string.Format("{0}//{1}", path, helpers.XmlDoc.ScrubFile(item.Alias));
            }
            return path;
        }
开发者ID:howej,项目名称:jumps.umbraco.usync,代码行数:14,代码来源:SyncTemplate.cs

示例10: GetFileContents

        internal static string GetFileContents(Template t)
        {
            string viewContent = "";
			string path = IOHelper.MapPath(ViewPath(t.Alias));

            if (File.Exists(path))
            {
                TextReader tr = new StreamReader(path);
                viewContent = tr.ReadToEnd();
                tr.Close();
            }

            return viewContent;
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:14,代码来源:ViewHelper.cs

示例11: CreateMasterPage

	    internal static string CreateMasterPage(Template t, bool overWrite = false)
        {
            string masterpageContent = "";

			if (!File.Exists(GetFilePath(t)) || overWrite)
                masterpageContent = SaveTemplateToFile(t, t.Alias);
            else
            {
				System.IO.TextReader tr = new StreamReader(GetFilePath(t));
                masterpageContent = tr.ReadToEnd();
                tr.Close();
            }

            return masterpageContent;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:15,代码来源:MasterpageHelper.cs

示例12: Template

        /// <summary>
        /// Converts an umbraco template to a package xml node
        /// </summary>
        /// <param name="templateId">The template id.</param>
        /// <param name="doc">The xml doc.</param>
        /// <returns></returns>
        public static XmlNode Template(int templateId, XmlDocument doc) {

            Template tmpl = new Template(templateId);

            XmlNode template = doc.CreateElement("Template");
            template.AppendChild(_node("Name", tmpl.Text, doc));
            template.AppendChild(_node("Alias", tmpl.Alias, doc));

            if (tmpl.MasterTemplate != 0) {
                template.AppendChild(_node("Master", new Template(tmpl.MasterTemplate).Alias, doc));
            }
            template.AppendChild(_node("Design", "<![CDATA[" + tmpl.Design + "]]>", doc));

            return template;
        }
开发者ID:saciervo,项目名称:Umbraco-CMS,代码行数:21,代码来源:utill.cs

示例13: CreateViewFile

        internal static string CreateViewFile(Template t, bool overWrite = false)
        {
            string viewContent;
			string path = IOHelper.MapPath(ViewPath(t.Alias));

            if (File.Exists(path) == false || overWrite)
                viewContent = SaveTemplateToFile(t, t.Alias);
            else
            {
                TextReader tr = new StreamReader(path);
                viewContent = tr.ReadToEnd();
                tr.Close();
            }

            return viewContent;
        }
开发者ID:CarlSargunar,项目名称:Umbraco-CMS,代码行数:16,代码来源:ViewHelper.cs

示例14: SaveToDisk

 public static void SaveToDisk(Template item)
 {
     if (item != null)
     {
         try
         {
             XmlDocument xmlDoc = helpers.XmlDoc.CreateDoc();
             xmlDoc.AppendChild(item.ToXml(xmlDoc));
             helpers.XmlDoc.SaveXmlDoc(
                 item.GetType().ToString(), GetDocPath(item) , "def", xmlDoc);
         }
         catch (Exception ex)
         {
             helpers.uSyncLog.ErrorLog(ex, "uSync: Error Saving Template {0} - {1}", item.Text, ex.ToString());
         }
     }
 }
开发者ID:howej,项目名称:jumps.umbraco.usync,代码行数:17,代码来源:SyncTemplate.cs

示例15: FindModule

        private HtmlNode FindModule(int template, string id, bool remove)
        {
            Template t = new Template(template);
            string TargetFile = t.MasterPageFile;
            string TargetID = id;

            HtmlDocument doc = new HtmlDocument();
            doc.Load(TargetFile);

            if (doc.DocumentNode.SelectSingleNode(string.Format("//*[@id = '{0}']", TargetID)) != null)
            {
                if (!remove)
                    return doc.DocumentNode.SelectSingleNode(string.Format("//*[@id = '{0}']", TargetID));
                else
                {
                    HtmlNode r = doc.DocumentNode.SelectSingleNode(string.Format("//*[@id = '{0}']", TargetID)).Clone();

                    doc.DocumentNode.SelectSingleNode(string.Format("//*[@id = '{0}']", TargetID)).RemoveAll();

                    doc.Save(TargetFile);

                    return r;
                }
            }
            else
            {
                if (t.HasMasterTemplate)
                    return FindModule(template,id,remove);
                else
                    return null;
            }
        }
开发者ID:saciervo,项目名称:Umbraco-CMS,代码行数:32,代码来源:SkinModule.cs


注:本文中的umbraco.cms.businesslogic.template.Template类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。