Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Hi Vishal!
I would create a IInitializableModule and listen to DataFactory event PublishedContent. It could look something like this:
[EPiServer.Framework.InitializableModule] public class DataFactorySubscriber : EPiServer.Framework.IInitializableModule { public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context) { context.InitComplete += InitComplete; } private static void InitComplete(object sender, EventArgs e) { DataFactory.Instance.PublishedContent += PublishedContent; } private static void PublishedContent(object sender, ContentEventArgs e) { var educationPage = e.Content as Education; if (educationPage != null) { CreateVariantPage("fulltime", e.ContentLink); CreateVariantPage("parttime", e.ContentLink); CreateVariantPage("dual", e.ContentLink); } } private void CreateVariantPage(string pageName, ContentReference parentLink) { bool alreadyExists = DataFactory.Instance.GetChildren<EducationVariant>(parentLink).Count(child => child.Name.Equals(pageName, StringComparison.InvariantCultureIgnoreCase)) > 0; if (alreadyExists) { return; } var variant = DataFactory.Instance.GetDefault<EducationVariant>(parentLink); variant.PageName = pageName; DataFactory.Instance.Save(variant, SaveAction.Publish, AccessLevel.NoAccess); } public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context) { context.InitComplete -= InitComplete; DataFactory.Instance.PublishedContent -= PublishedContent; } public void Preload(string[] parameters) { } }
Hope that helps!
Hi there,
I have a pagetype called Education. Now when i create a page of that PageType and publish it, i want to auto create 3 subpages of another pagetype called EducationVariant and have all 3 items have the pageName 'fulltime', 'parttime' and 'dual' respectively and then publish them(or save/unpublished).
how would i go about doing this in EPiServer 8 (latest updates)?