本文整理汇总了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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
}
}
示例5: UpdateMasterPageFile
internal static string UpdateMasterPageFile(Template t, string currentAlias)
{
var template = UpdateMasterPageContent(t, currentAlias);
UpdateChildTemplates(t, currentAlias);
SaveDesignToFile(t, currentAlias, template);
return template;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
}
}
示例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;
}
}