Editor Extensions – Copy a page with its components

What Sitecore standard copy functionality does:

  1. Copies the whole item tree under the selected item
  2. Copies all item versions (if you have more)
  3. All references (included the datasources in your components) remain the same

So in some cases it is good but especially when you have pages with local component datasources the standard copy function does not really for you.

To solve this problem implemented the following solution but it has some prerequisites:

  1. The Page item should have folder item named Content, the the item identicated as a Page
  2. The Content folder should contain all local datasource items for the actual Page

What this button does?

  1. Creates a new item from the selected item with the Content item recursively
  2. Creates new language versions from the last version of the selected Page item
  3. Sets the new item’s datasource references in the Final Layout and Shared Layout
  4. Sets the new item’s rule action datasource references in the Final Layout and Shared Layout

At first I have the following config which registers a command for the button in Content Editor and a processor which does the main job.

Here we have the command which calls the pipeline.

Here is the referenced pipeline.

As you can see it calls the another service class where I have implemented the main logic.

I have some extra class which are the model and constant classes.

At the end create a button in the Core database.

  • Path: /sitecore/content/Applications/Content Editor/Ribbons/Chunks/Operations
  • Name: Copy Page To
  • Click field: skeleton:copypage

Aaaand here is the new button!

Capture

Happy copying!

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s