Sitecore has a very powerful publishing architecture, which is perfect for almost all cases, but sometimes, we may need to override the publishing engine as per our requirement. The <publishItem>
pipeline contains many processors playing different roles in publishing items.
A very common challenge in Sitecore is to deal with duplicate item names in a single parent. In this recipe, you will learn how we can achieve a unique item name in a single parent after publishing.
We will create a custom processor in the <publishItem>
pipeline:
In the
SitecoreCookbook
project, create aRemoveDuplicateItems
class in thePublishing
folder and inherit it fromPublishItemProcessor
.Override the
Process()
method of thePublishI
temProcessor
class:public override void Process(PublishItemContext context) { Item sourceItem = context.PublishHelper.GetSourceItem(context.ItemId); if (sourceItem != null) { ...