Second, go to the folder (specified in web.config, key "XMLDataPath") , look in the folder "ProcessMap_published" for your .png that looks familiar. Memorize that GUID.
Then goto folder "ProcessMap_XMLDefinitions" and rename that <GUID>.xml file to for example template1.xml.
Then in Global.asax.cs, add event:
DataFactory.Instance.LoadedDefaultPageData += new PageEventHandler(Instance_LoadedDefaultPageData);
and the methods:
//ProcessMap logic for creating page and template to be used
void Instance_LoadedDefaultPageData(object sender, PageEventArgs e)
{
// skip all other page types than processmap page, assuming this pagetype is named process..something
if (!e.Page.PageTypeName.ToLower().Contains("process"))
return;
bool hasProcessMap = false;
string processMapPropertyName = "";
foreach (PropertyData py in e.Page.Property)
{
if (py.GetType().ToString() == "ProcessMap.EPiServerCMS.Property.PropertyProcessMap")
{
hasProcessMap = true;
processMapPropertyName = py.Name;
}
}
if (!hasProcessMap)
return;
// If property holds any value, dont overwrite it
if (e.Page.Property[processMapPropertyName].Value != null && !string.IsNullOrEmpty(e.Page.Property[processMapPropertyName].Value.ToString()))
return;
e.Page.Property[processMapPropertyName].Value = CreateProcessMapTemplateCopy("template1.xml");
}
//copies the template xml into a new GUID
string CreateProcessMapTemplateCopy(string templatename)
{
string path = Utilities.GetAppSetting("XMLDataPath");
FileInfo file = new FileInfo(path + "\\" + templatename);
string newfilename = System.Guid.NewGuid() + ".xml";
string newfile = path + "\\" + newfilename;
if (!file.Exists)
return string.Empty;
FileInfo filenew = file.CopyTo(newfile, true);
return newfilename;
}
An there you go!
Inga kommentarer:
Skicka en kommentar