Content Folders, which are located in assets pane gadget or multichannel content gadget, allow you to add any type of block or folders. But sometimes, for specific folders, we would like to store only one type of content and additional folders used for example for clustering or grouping. In this article, I will describe how to limit the types of content that can be added to a folder.

Create custom folder type in Edit Mode

Example use case

For example, a client would like to have folders to store only one type of blocks. One folder will contain blocks with recipes and the other will contain blocks with recipe ingredients. In addition, some recipes and ingredients could be grouped in subfolders, such as “Swedish recipes”, “Spicy ingredients” etc. The structure would look as follows:

Create custom folder type in Edit Mode structure

To force the Recipes folder to contain only recipe blocks and subfolders with recipy blocks we can add a new folder type that inherits from the built-in ContentFolder type. The inheriting folder will be defined with AvailableContentTypes attribute. Initial folders can be configured using InitializationModule. A similar example is described in the following article.

Below is a code with conte types definition

Adding custom folder type in Edit Mode

In Edit Mode, you can create different types of blocks and pages, while there is no built-in mechanism for creating a specific folder type. By default, only the base folder type ContentFolder can be created. This means that you can not create a folder “Swedish resipes”, which will be of type RecipeContentFolder.

This can be solved by registering custom command.

Multichannel component

To enable the creation of selected folder types in the Multichannel Content gadget, we can use “epi-cms/plugin-area/navigation-tree” plugin area. To add new folder, the code from default NewFolder command will be used, but it will be called with a different folder type.

In addition to the client code, we need to translate the texts used as the command label and the default name of the new folder.

Alternative solution

If you don’t want to add code in the dojo, you can, for example, add a plugin in Admin Mode that allows you to select the parent folder and the type of folder to be added. However, this solution requires administrative rights.

New custom folder type in assets pane gadget

To allow adding specific folders in the assets pane, we need to use “epi-cms/plugin-area/assets-pane” plugin area. As in the previous code snippet, we will use NewFolder command, but run with a different content type.

By using folders with defined AvailableContentTypes, folders will only contain the specified block types

creating custom folders