5

I have noticed that the Sitecore.Buckets.LinkProviders namespace has 2 classes that extend the default LinkProvider: ScalableLinkProvider and ItemSearchLinkProvider. I cannot find any direct references to them in either code or config and I cannot find any documentation or blogs that mention them.

Can anyone tell me what the intended purpose of these classes is? Are there certain scenarios where I should use or derive from one of these link providers rather than the default Sitecore.Links.LinkProvider?

1 Answer 1

4

ItemSearchLinkProvider

ItemSearchLinkProvider is a very simple provider with GetItemUrl method which:

  1. Checks if item is inside a bucket
  2. If no it returns base.GetUrl - where base class is Sitecore.Links.LinkProvider
  3. If yes, it generates url in a format:
return string.Format("/{0}/{1}/{2}/{3}", 
    item.GetParentBucketItemOrSiteRoot().Name.ToLower(), 
    item.Statistics.Created.ToString("yyyy-MM-dd"), 
    item.ID.Guid.ToString().Substring(0, 4), 
    item.Name.ToLowerInvariant());

So for example if your My Last Article item is insiade a bucket called News, was created on 17th of July 2018 and its id is {360CB29F-4BF7-405C-916A-C1C4C2378902}, the url will be:

"/news/2018-07-17/360c/my last article"

In my opinion, this format has no usage. I don't see any reference from the code or config to this class.

ScalableLinkProvider

ScalableLinkProvider uses its own internal class DatedLinkProvider to generate url with format:

`/ancestors/up/to/site/root/itemname-201807171457`

where the numbers at the end are parent folders from the date and time in bucket structure in yyyyMMddHHmm format.

There is also a ScalableLinkResolver class which you could use to resolve the urls generated by ScalableLinkProvider.

2
  • Thanks, Marek. So the only reason I would use ScalableLinkProvider is if I prefer that URL format over the default?
    – Ben Golden
    Aug 10, 2018 at 21:06
  • I think so. The only difference is that instead of generating urls with /yyyy/MM/dd/HH/mm it adds -yyyyMMddHHmm at the end of the url. I'm not sure how it would work if your bucket is not under StartItem of your site. I've never used this provider on my own.
    – Marek Musielak
    Aug 10, 2018 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.