Sitecore tags and Multi Site in Action

Today, I was playing with tags and so we have implemented the tag field written in this blog post but with some modifications.

We wanted :

  • Tags per site
  • Tags outside the System/Settings
  • Mutli Tag Folders

This has been implemented on a Sitecore 7.2 Update 2

So for that, First create a tag template (or use the one from Sitecore) then a root folder which will be created under your Site node, then if needed an other template to store tags ( So Root – Tag folder – Tag).

Then create a new Base Tag template which will contain a MultiList with search configured to your root node (the one you created before) (This was the datasource of my MultiList With Search (don’t put _template or _templatename does not work (By debugging the query via the search log Sitecore adds a _ automaticly))


Where StartSearchLocation is my Root folder of tags folder. And I simply filter by Template (tag template) Now put this field on items template that need tagging and begin to … tag

If you try to search with the search tab (Tab of Item Bucket) it will not work (Putting a tag:TagName) won’t find anything because he’s still looking for tags in your tag repository in System/Settings/Buckets/Tag Repository. So, we have to do multiple things:

  • Create a new item bucket setting for your site (Just duplicate the existing one) and set the Tag Parent to your tag parent. (In Sitecore/System/Settings/Bucket/ )
  • Create a new Tag Repository (In Sitecore/System/Settings/Bucket/Tag Repositories)
  • Set the type to a class created in your project and check the Enable checkbox

We will create a class which implements ITagRepository. (you can reuse this one, it should work, but if you don’t like how I do the mutli site resolving or something you can do it as you want).


It’s a copy paste of the class  SitecoreHostedTagRepository where I changed the way of getting the Settings and to resolve the site. So, the class introduces two properties stored in the <site> node :

  • tagRepositorySettingId : Which is the ID of your Settings Item
  • tagRepositoryTagTemplateId : Which is the ID of the Tag Repository (In Sitecore/System/Settings/Bucket/Tag Repositories)

So don’t forget to put them on your <site> node in your config. Now your customer should be able to tag their content without having the tags of other people.

I didn’t try to solve the issue of searching for a specific tag folder with the bucket search (But it should not be hard (you can filter the list in the GetTag method) and you can create multiple tag templates to set the datasource elsewhere when you filter with your multilist.


Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *