8

I have an item that will contain a large number of subitems as direct children, which I would like to give bucketing treatment to.

Unfortunately these items don't have a reasonable way to be grouped in subfolders.

I've created a custom rule in Item Bucket Settings:

Example Rule
where the item bucket is based on the [Examples] template
  and where the new bucketable item is basedon the [Example] template
create the new folder structure based on the name of the new bucketable item with [0] levels

Choosing 0 levels defaults the bucket path to use the creation date of the item in the default yyyy/MM/dd/HH/mm format.

Is there a way to bucket these items without the intermediate folders?

I'd prefer that they be accessed at http://example.com/examples/example-name rather than http://example.com/examples/ ... path here ... /example-name, and I'd rather not need to introduce a * item just to correct the paths.

  • Is there any reason for creating a bucket in the first place then? Buckets were introduced to avoid the performance issues when an item has more than 100 direct children. This is not only an issue in the UI, but also when executing queueries. – Kasper Gadensgaard Oct 20 '16 at 18:47
  • @KasperGadensgaard, mostly for the UI enhancements. This item will have more than 100 children, and accessing those items will still happen through the queryable API. – zzzzBov Oct 20 '16 at 18:50
  • @zzzBov you can still get the UI enhancements without the parent item being a bucket, if you mean the search UI part. If that is what you want can you update your question with that? We don't have to limit it to solving the Item Bucket folder option then – Richard Seal Oct 20 '16 at 19:03
  • @RichardSeal, I'm not going to limit my question just because it'd be convenient. – zzzzBov Oct 20 '16 at 19:04
  • 2
    I my humble opinion you are setting yourself up for a world of pain. There are several really good reasons why the number of child items should be limited, particularly performance and caching. Let buckets work like they should and look into URL manipulation/item resolving to achieve the nice URLs. – Eldblom Oct 21 '16 at 21:10
10

This answer does not exactly match your question, but I believe it matches your requirements based on the comments you have made.

If you want the Item Bucket search features on the parent item but do not want the child items added into sub folders you can easily add those features to the parent item.

Make sure that you can view Standard Fields and find the Editors field of the parent item. Then you can add the Search editor to the list and move it to the top so it becomes the default:

enter image description here

If you have multiple items based off the same template you can also do this on the Standard Values of the item.

enter image description here

Then you have all the search features and can just add child items as normal.

Edit:

To make the sub items hidden then you can set that on the standard values of the templates of the items you add to the parent:

enter image description here

This items will only be visible if the Hidden Items checkbox on the View ribbon is ticked:

enter image description here

  • This would work so long as I never expand the parent or ever look at the items it contains. – zzzzBov Oct 20 '16 at 19:19
  • @zzzzBov I have included an edit that enables you to do that. – Richard Seal Oct 20 '16 at 19:26
  • Oh good point with the hidden items. It is a bit strange, but the whole situation is a bit strange. – zzzzBov Oct 20 '16 at 19:28
5

Yes, there is. I wrote a bog post about it:

https://www.skillcore.net/sitecore/sitecore-item-buckets-custom-folders-structure

In shoortcut you need to create action extending RuleAction<T> where T : BucketingRuleContext and set ruleContext.ResolvedPath to whatever you want.

Here is the example of action which adds author user name to the folder structure:

public class AuthorAndCreateDateBasedPath<T> : CreateDateBasedPath<T> where T : BucketingRuleContext
{
  public override void Apply(T ruleContext)
  {
    base.Apply(ruleContext);
    if (Sitecore.Context.Data != null && Sitecore.Context.Data.User != null)
    {
      ruleContext.ResolvedPath = 
        Sitecore.Context.Data.User.LocalName + "/" + ruleContext.ResolvedPath;
    }
  }
}

You can create your action in similar way.

Then we create new Action under /sitecore/system/Settings/Rules/Definitions/Elements/Bucketing item and set Text and Title fields like that:

enter image description here

  • Thank you for updating your post, however I think you're misunderstanding my question. I'm not asking about how to create a custom bucket path as I've already written about it myself. I'm asking how to make the custom path empty, which is getting overridden by Sitecore's default pathing behavior. – zzzzBov Oct 20 '16 at 18:39
  • You're welcome. I think Iunderstood your question. What I suggest is to create a custom action which will set the path to empty string or whatever you need. From what I know you cannot do this with Sitecore out of the box actions. That's why I showed all the necessary steps. You just need to change one line which sets path to "author + basedResolvedPath" (and naming). And that should be it. – Marek Musielak Oct 20 '16 at 18:43
  • I appreciate the work you've put into this answer, and to be absolutely certain, I wrote a custom rule that sets the ruleContext.ResolvedPath to empty string. Testing gives me the same yyyy/MM/dd/HH/mm result as I described in the question. To be sure I had everything configured properly, I also tested it with a value of "foo", which worked as expected, putting all items in a foo bucket. – zzzzBov Oct 20 '16 at 18:58
  • I've run into an interesting situation. Out of curiosity I updated ruleContext.ResolvedPath to "/" and bucketing now "works" with the items directly under the bucket, however creating items triggers a save dialog and the UI no longer hides subitems with the "there are hidden items..." message. – zzzzBov Oct 20 '16 at 19:11
  • @zzzzBov that is because the way an item bucket hides the content is because the Bucket Folders are marked as hidden on the std values. Same way as my answer – Richard Seal Oct 20 '16 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.