George
George

Reputation: 2200

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?

Upvotes: 3

Views: 2584

Answers (2)

Dheer Rajpoot
Dheer Rajpoot

Reputation: 74

You can change the bucketing strategy by two ways:

  1. Using predefined bucketing rules. Navigate to item bucket settings stored at /sitecore/system/Settings/Buckets location and create a new rule (Bucketing Strategy: Item Creation Date) for resolving the bucket folder path.

  2. Writing custom code for bucketing strategy. Write CustomBucketFolderPathResolver class which implements IDynamicBucketFolderPath interface and return folder path.

Detail information can be found at below post:

http://www.bugdebugzone.com/2014/07/configuring-sitecore-item-buckets-with.html

http://www.bugdebugzone.com/2014/07/configuring-sitecore-item-buckets-with_19.html

Upvotes: 4

Chris van de Steeg
Chris van de Steeg

Reputation: 804

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/

Upvotes: 8

Related Questions