Try our conversational search powered by Generative AI!

Copied page with the same name


I was wondering if there is any way to append a text at the end of the copied page name to avoid confusion, so once user copies a page with name "Test" , the dupicated page has a name as "Test-Copy" .

Sep 30, 2013 12:56

Andreas Nicolaisen at EPiNova created a blog post about a similar function:

I'm not certain if you can put it on the CreatedPage event or if it really needs to be on the PublishedPage since you might copy an unpublished Page.

The key is that e.Page should be null.

Sep 30, 2013 13:27

Thank Alf. I tried this but it would not work. The problem is that the name does not change in treeview before the user publishes the page. Any solution for this?

Sep 30, 2013 15:31

As I mentioned, I'm not sure whether you can change this to hookup to the CreatedPage event instead.

Could you change and see if this would add the name on create instead of publish?

Sep 30, 2013 15:34

Or CreatingPage event instead?

Sep 30, 2013 15:41

Yeah might even be better and then I guess you don't need to save the page separately.

Unfortunately I'm not able to try this out myself at the moment so all I can give are hints.

Sep 30, 2013 15:44

Thank you both. I have actually used CreatedPage. The problem with using CreatingPage is that the Page property in PageEventArgs (CopyPageEventArgs) passed to CreatingPage is  null so is PageLink. There is a SourceLink property which has the link to the page that is being copied but I would have to do the copying myself and it might get messy.

Sep 30, 2013 16:26

HI Reza,

would it be possible to add a snippet of how you did this... because if you hook into the createdPage event, how did you check if this was a new page or a copied page of an existing page..

Aug 03, 2015 11:29

This if what i have for now

    public class DataFactorySubscriber : IInitializableModule
        public void Initialize(EPiServer.Framework.Initialization.InitializationEngine context)
            context.InitComplete += InitComplete;

        private static void InitComplete(object sender, EventArgs e)
            DataFactory.Instance.CreatedContent += CreatedContent;            

        private static void CreatedContent(object sender, ContentEventArgs e)
            var content = e.Content;

            if (content != null)
        private static void CreateCopyPage(ContentReference contentLink)
            var repo = ServiceLocator.Current.GetInstance<IContentRepository>();
            //check if exists
            bool alreadyExists = repo.Get<PageData>(contentLink).GetSiblings().Where(p => p.Name == repo.Get<PageData>(contentLink).Name).Any();

            if (!alreadyExists)
            var variant = repo.Get<PageData>(contentLink);
            var clone = variant.CreateWritableClone();
            clone.PageName = variant.Name + " - Copy";            
            clone.URLSegment = "";
            // Does this page have a simple address?
            //clone.SetPropertyValue(p => p.URLSegment, "");
            DataFactory.Instance.Save(clone, SaveAction.Save, AccessLevel.NoAccess);

        public void Uninitialize(EPiServer.Framework.Initialization.InitializationEngine context)
            context.InitComplete -= InitComplete;
            DataFactory.Instance.CreatedContent -= CreatedContent;            

        public void Preload(string[] parameters)

The problem is two fold: It was first complaining that the URL in Name is already in use. So i set the URLSegment to "" .

But still my copied page doesnt get the new pageName with  -Copy behind it. And this fails completely if there the page being copied containt contentassetfolders (blocks for example).

What would be a correct way to rename a copied page (with or without assets) from code?

Edited, Aug 03, 2015 13:43
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.