In this article, I will show simple code that allow to replace linked content with other content selected by the Editor. When deleting content whose references are used by other content, the Editor is shown a dialog box with a list of references. The Editor has the option to visit the page or block where the deleted content is used. However, it would be much more convenient to be able to replace the deleted content with another content selected from the list of pages.

Update content refrences

In the extended dialog, the Editor has the option of replacing a single usage of a link (“Replace…” button), or replacing all usages at the same time (“Replace all” button). When replacing a link, the editor is presented with a content selection dialog. After selecting content from the tree and confirming with the “Change” button, the linked content is replaced with the new content and the list of references is refreshed.

Update content references dialog

The extension supports several property types: ContentArea, ContentReference, XhtmlString (TinyMCE), LinItemCollection, LinkItem and ContentReference list. When replacing a reference, the current version of the content is overwritten. It can be easly extended in TryUpdateProperty method.

Below you can find an example of replacing the content

Update content references preview

Extension contains two files. Javascript initialization module where dialog is extended and C# REST store responsible for updating content links.

Code is available as Github gist