Customizing the publishItem pipeline to avoid duplicate names on a live site
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.
How to do it…
We will create a custom processor in the <publishItem>
pipeline:
- In the
SitecoreCookbook
project, create aRemoveDuplicateItems
class in thePublishing
folder and inherit it fromPublishItemProcessor ...
Get Sitecore Cookbook for Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.