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

北战南征 提交于 2019-12-19 09:55:55

问题


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?


回答1:


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/




回答2:


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



来源:https://stackoverflow.com/questions/24751818/how-do-i-bucket-sitecore-items-on-something-other-than-their-creation-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!