In Sitecore 9.3, the way Link Resolver works has changed from previous versions and sitecore documentation link has details about the changes.
Today, in this blog, we will see how we implement custom link provider by overwriting the default link provider.
Why do this?
Consider a scenario where we are using sitecore wildcards (*) and actual items are present in say “Global” section of the content tree or a scenario, where we have blogs that are organized in Year/Month/day/<<BlogName>> i.e. actual item url is long and we want to shorten the url to say /blogs/<<BlogName>> without actually moving the sitecore content items.
In this case, we will need to implement custom itemresolver which will dynamically resolve the url to the correct format.
Also read: Sitecore Platform Inspection – How To Get Most Out Of It
In order to do this, we will need to write CustomItemBuilder Class that inherits from default sitecore 9.3 ItemUrlBuilder class.
We will need the constructor to inherit from the base constructor.
We will then need to override the default Build() method as per below screenshot.
Once we write our logic to resolve the item url, we will need to create patch config file and reference it to the class that we have written above.
Also read: Personalization Buzzwords Explained
Below is the example of patch config file.
The above example is overriding the item resolver and we will need to do similar logic changes in case we need to resolve media items.
Contact us now to learn more about our services related to Sitecore