Global content sharing strategy for buckets and repositories in Sitecore

5/21/2018 sitecore-buck sitecore-wildcards sitecore-best-practises

If you have a global section with a repository of items in Sitecore buckets and are shared between different Sitecore websites in a multi-site environment, here is the way how to deal it in a nicer way.

Let's imagine we have a repository of products in Sitecore buckets, which will be used by multiple websites. If we need to render these products on different websites, there are many ways we can approach this.

  • Wildcards and custom code on wildcard page layout to render product details.
  • Wildcard pages and making context item as the product item
  • using custom item resolver

There are pros and cons in all above cases, the solution I found best is using wildcard pages and making product item as the context item.

It has many advantages, by doing this way we can use Sitecore out of the box personalisation, experience editor works as good as normal website item. The only con is it needs a little bit of customisation.

So let's see how we can do this.

Firstly we need to add a new processor at the end of mvc.getPageItem pipeline like:

        <processor patch:after="processor[@type='Sitecore.Mvc.Pipelines.Response.GetPageItem.GetFromOldContext, Sitecore.Mvc']" type="sitecoreblog.tools4geeks.SitecoreCustom.Pipelines.Response.GetPageItem.GetForWildcardPages, sitecoreblog.tools4geeks.SitecoreCustom"/>


Second step is to implement the processor.

public class GetForWildcardPages : GetPageItemProcessor
	Assert.ArgumentNotNull(args, "args");
            if (args.Result != null)
                if (args.Result.TemplateID == new ID(TemplateIds.productWildcard))
                    var path = args.RouteData.Values.FirstOrDefault(x => x.Key == "pathInfo").Value.ToString();
                    var productId = GetIdFromPath(path);

                    if (!string.IsNullOrEmpty(productId))
                        var product = GetComposerItem(productId);
                        if (product == null)
                           //set 404 status code.
                        args.Result = product;


I feel this is the cleanest way of using repositories in Sitecore website. Please let me know in comments if you had a better idea.

The other two approaches are not good for personalisation and experienced editor.