Search code examples
sitecoresitecore7sitecore-dmssitecore7.2

How do I bucket Sitecore items on something other than their creation date?


I'm using Sitecore with DMS (Sitecore 7.2), and I'm setting up various controls on my layouts to pull content from different folders based on the users profile card. I'd like those folders to be "bucket" folders, since there'll be one folder for each profile card, and it'll be a bit unpleasant for authors to have to manually update all of these folders every time a new profile card is added.

The "Developers Guide to Item Buckets and Search" says:

by default, the items are organized according to the date and time of when the item was created, but this can be configured to use different behavior

Ideally I'd like to bucket my items on a field defined in a template that all of my "bucketable" item templates inherit from. I'll set that field to be a select dropdown from the list of profile cards.

I've found the Sitecore Autohaus demo with the Bucketing.GuidFolderPath class - looks like I need to define one of these classes with a GetFolderPath method? But then how do I tell my Sitecore bucket item that I want to bucket using that class?


Solution

  • You can indeed use a custom IDynamicBucketFolderPath and set that in the config (BucketConfiguration.DynamicBucketFolderPath), but that will change your default for all buckets.

    You can define rules in sitecore to specify the folderstructure for a specific path/template/id/etc. By default there are 3 rules: CreateDateBasedPath, CreateIDBasedPath and CreateItemNameBasedPath, but you can ofcourse add your own rules under /sitecore/system/Settings/Rules/Definitions/Elements/Bucketing/