public Template GetTemplate(string templatename) { var templatepath = string.Format("{0}\\{1}\\{2}", TemplateMapPath.TrimEnd('\\'), "Default", templatename); var objT = new Template(templatepath); return(objT); }
/// <summary> /// Get template from language, System or Portal level /// </summary> /// <param name="templatename">Template Name</param> /// <param name="lang">language</param> /// <param name="themesubfolder">the subfolder of the theme, usually "Default","css","resx","js","img". But can be anything. </param> /// <returns></returns> public Template GetTemplate(string templatename, string lang, string themesubfolder) { var templatepath = string.Format("{0}\\{1}\\{2}", TemplateMapPath.TrimEnd('\\'), lang, templatename); if (templatename.StartsWith("/") | templatename.StartsWith("{")) { templatepath = HttpContext.Current.Server.MapPath(templatename); templatepath = templatepath.Replace("{LANG}", lang); } var objT = new Template(templatepath); if (objT.Exists() == false) { templatepath = string.Format("{0}\\{1}\\{2}", TemplateMapPath.TrimEnd('\\'), themesubfolder, templatename); if (templatename.StartsWith("/") | templatename.StartsWith("{")) { templatepath = HttpContext.Current.Server.MapPath(templatename); templatepath = templatepath.Replace("{LANG}", themesubfolder); } objT = new Template(templatepath); } if (objT.Exists() == false) { templatepath = string.Format("{0}\\{1}\\{2}", TemplateConfigMapPath.TrimEnd('\\'), themesubfolder, templatename); if (templatename.StartsWith("/") | templatename.StartsWith("{")) { templatepath = HttpContext.Current.Server.MapPath(templatename); templatepath = templatepath.Replace("{LANG}", themesubfolder); } objT = new Template(templatepath); } return(objT); }
/// <summary> /// get list of langauge Specific files. this function only returns the template files matching the lang passed in the lang param /// </summary> /// <param name="lang">Culture Code.</param> /// <returns></returns> public Dictionary <string, string> GetSpecificTemplateFileList(string lang = "Default") { var templateList = new Dictionary <string, string>(); //Get all the langauge Specific templates var folderPath = string.Format("{0}\\{1}\\", TemplateMapPath.TrimEnd('\\'), lang); if (Directory.Exists(folderPath)) { var langfiles = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories); foreach (string file in langfiles) { if (Path.GetFileName(file) != null) { var fkey = Path.GetFileName(file); if (fkey != null) { if (templateList.ContainsKey(fkey)) { templateList.Remove(fkey); templateList.Add(fkey, file); } else { templateList.Add(fkey, file); } } } } } return(templateList); }
public void SaveTemplate(string templatename, string lang, string templatedata) { var langpath = string.Format("{0}\\{1}\\", TemplateMapPath.TrimEnd('\\'), lang); if (!Directory.Exists(langpath)) { Directory.CreateDirectory(langpath); } var templatepath = string.Format("{0}\\{1}\\{2}", TemplateMapPath.TrimEnd('\\'), lang, templatename); var objT = new Template(templatepath); objT.Save(templatedata); }
private void SetupThemeFolders(string themefolder) { var folderPath = string.Format("{0}\\{1}\\", TemplateMapPath.TrimEnd('\\'), themefolder); if (!Directory.Exists(folderPath)) { try { Directory.CreateDirectory(folderPath); } catch (Exception) { // we might get an error if it's an invlid path, created by export import DNN portals onto different system folder // we can ignore these, becuase when editing a module template the setting should re-align when updated. } } }