Control Which Document Types Can Be Created in a Folder

Overview

You can restrict which document types users can create within a specific folder in Bloomreach Content. This allows you to guide content authors and enforce consistent content structures.

When to Use

Restrict allowed document types in a folder to:

  1. Reduce the number of choices for authors, making content creation more straightforward.
  2. Ensure all documents in a folder (and its subfolders) share the same type, which simplifies delivery tier implementation—especially when using wildcard sitemap items such as /products/**.html.

How It Works

The set of document types available in a folder is determined by a query. By default, all document types are available. You can override this behavior by configuring a custom query for a folder, limiting which document types can be created there.

This page covers two main approaches:

You can also add a custom icon for menu items.

BeforeAfter
------
Folder context menu showing allowed content editing optionFolder context menu with Edit allowed content option
New document dialog with document type dropdown expandedNew product dialog with name and URL name fields

Using Document Types Included with Out-of-the-Box Features

When you add out-of-the-box features such as News or Events, the folders created by these features are typically pre-configured to allow only the relevant document type.

You can create additional folders and configure their document type restrictions through the CMS user interface.

Example: Restricting a Folder to "News" Documents

Assume your project includes the "News" feature and you have created a "press releases" folder. You want to restrict this folder so that only "news" documents can be created inside it.

  1. In the Content application, navigate to the "press releases" folder.

  2. Right-click the folder and select Edit allowed content... from the context menu.

    Context menu on press releases folder with Edit allowed content

  3. The folder will show the default queries (Add new translated folder and Add new document). Remove both by clicking the X icon in the Actions column.

    Edit allowed content dialog for press releases folder

  4. At the bottom of the dialog, select Add new news folder and Add new news item from the dropdown.

    Edit allowed content dialog with template query dropdown open

  5. The folder is now configured to allow only "news" documents and "news folders" (which applies the same restriction to subfolders).

    Edit allowed content dialog for press releases folder

  6. Click OK to save the changes.

The context menu for the "press releases" folder now only shows options to add a news folder or news item:

Context menu for press releases folder with restricted add options

Manual Configuration for Custom Document Types

If your project uses custom document types (not provided by out-of-the-box features), you need to define template queries for those types before you can restrict folder content.

You can generate template queries for custom document types using the Template Query Generator (part of the Essentials development tools). Alternatively, you can configure template queries manually in the Console.

Example: Restricting a Folder to a Custom Document Type

Goal: Restrict the folder /content/documents/myproject/products so that only documents of type myproject:product can be created.

1. Create a Template Query for the Product Document Type

  1. In the console, copy the node:

    /hippo:configuration/hippo:queries/hippo:templates/new-document
    

    to:

    /hippo:configuration/hippo:queries/hippo:templates/new-product
    
  2. Update the query to allow only the myproject:product document type:

    /hippo:configuration/hippo:queries/hippo:templates/new-product: jcr:statement: //element(*,hipposysedit:namespacefolder) /element(*,mix:referenceable) /element(*,hipposysedit:templatetype) /hipposysedit:prototypes /element(hipposysedit:prototype,myproject:product)

    Only the last part of the JCR statement changes from hippo:document to myproject:product.

  3. Update the i18n label:

    /hippo:configuration/hippo:translations/hippo:templates/en: new-product: new product
  4. Save your changes.

2. Create a Template Query for Subfolders

To ensure child folders also restrict document types to myproject:product, configure a query for subfolders.

  1. Copy the node:

    /hippo:configuration/hippo:queries/hippo:templates/new-translated-folder
    

    to:

    /hippo:configuration/hippo:queries/hippo:templates/new-product-folder
    
  2. Update the JCR statement for creating child folders:

    /hippo:configuration/hippo:queries/hippo:templates/new-product-folder: jcr:statement: /jcr:root/hippo:configuration/hippo:queries/hippo:templates /new-product-folder/hippostd:templates/node()

    Change new-translated-folder to new-product-folder.

  3. Set the available queries for new product folders:

    /hippo:configuration/hippo:queries/hippo:templates/new-product-folder/hippostd:templates/hippostd:folder: hippostd:foldertype: [new-product-folder, new-product]

    These values correspond to the JCR node names of the queries you created.

  4. Update the i18n label:

    /hippo:configuration/hippo:translations/hippo:templates/en: new-product-folder: new product folder
  5. Save your changes.

3. Configure the Folder to Use the New Queries

Note: This step is performed in the CMS UI and follows the same process as for out-of-the-box document types.

  1. In the Content application, select the myproject > products folder.
  2. Open the context menu and select Edit allowed content.
  3. Remove any existing options.
  4. Add Add new product folder... (new-product-folder) and Add new product... (new-product) from the dropdown.
  5. Click OK to save.
  6. The context menu for the "products" folder now includes only the options to add a new product folder or a new product.

Use a Custom Icon

By default, menu items use a folder icon if the query name ends with "folder" (for example, new-product-folder), or a document icon otherwise.

To use a custom icon for a menu item, add an SVG icon (16x16 pixels) to the following directory in your project:

cms/src/main/resources/org/hippoecm/frontend/plugins/standardworkflow

Name the icon file after the query name, with -tiny appended. For example, for the query new-product, use:

cms/src/main/resources/org/hippoecm/frontend/plugins/standardworkflow/new-product-tiny.svg

After rebuilding and restarting the application, the menu item will display the custom icon.

Note: For backward compatibility, you can use a 16x16 PNG icon (for example, new-product-16.png), but SVG icons are recommended for better appearance.

Limitations

Document type restrictions apply only when creating new documents in a folder. They do not prevent users from copying documents of other types into the folder from elsewhere.

Share Feedback
Page: /build/document-types/document-types/control-the-allowed-document-types-in-a-folder
Section: Build
Category *
Control Which Document Types Can Be Created in a Folder | Bloomreach Content Documentation