Content tagging Sitecore 9 and 10's: create Custom Folder Structures in Sitecore 9 and 10's TAP Repository for Bucket Management

30 Views Asked by At

I have been trying to implement an approach for a custom folder structure in the tap repository on buckets. In this approach, I have commented out the following line:

<!-- <setting name="BucketConfiguration.BucketFolderPath" value="yyyy\/MM\/dd\/HH\/mm"/> -->

in Sitecore.Buckets.config file.

However, even after doing this, when I click on the tag button, the Sitecore tagging job runs and creates the same folders like yyyy/MM/dd.

Bucket config

Folder structure

If I disable the default BucketFolderPath setting, then we can implement the following setting:

<setting name="BucketConfiguration.DynamicBucketFolderPath" value="Sitecore.Buckets.Util.BucketFolderPathResolver, Sitecore.Buckets"/>

in the Sitecore.Buckets.config file. By enabling this setting and using the IDynamicBucketFolderPath interface, we should be able to customize the folder structure. In the GetFolderPath function and bucket rules, we can implement our own folder structure.

However, I'm still facing a blocker. Despite commenting out the BucketConfiguration.BucketFolderPath setting, it still creates the same folders using the pattern yyyy/MM/dd. I have tried a lot, but I haven't found a solution yet. If anyone has any ideas or knows a way to disable this behavior, please let me know.

Ref URL: https://doc.sitecore.com/xp/en/developers/90/sitecore-experience-manager/custom-bucket-structures.html

1

There are 1 best solutions below

0
Anna Gevel On

This happens because Sitecore falls back to the default value yyyy\\/MM\\/dd\\/HH\\/mm if the setting BucketConfiguration.BucketFolderPath is missing:

public class BucketConfigurationSettings
{
    public static string BucketFolderPath => Settings.GetSetting("BucketConfiguration.BucketFolderPath", "yyyy\\/MM\\/dd\\/HH\\/mm");
}

So commenting out this setting does not actually change anything because the same value is specified in the code by default.

The preferred approach for customising bucket folder structure is adding rules to the item /sitecore/system/Settings/Buckets/Item Buckets Settings, for example the rule below will create 3-level folder structure based on the first characters of item name:

Rules for custom folder structure

Please note that the setting BucketConfiguration.BucketFolderPath is only used if no rules are added to the item Item Buckets Settings. So if you keep the rules field empty, it is possible to modify the setting BucketConfiguration.BucketFolderPath via a config patch similar to this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <sitecore>
    <settings>
      <setting name="BucketConfiguration.BucketFolderPath" value="yyyy"/>      
    </settings>
  </sitecore>
</configuration>

Value of this setting should either be a date format or a static string. If you replace it with an empty string, it will create a folder with the name "Repository" be default.

Hope this explains how bucket folder resolving works in Sitecore.