---
title: "Example: Code for the Insert Options pipeline processor to allow folders anywhere"
slug: "example--code-for-the-insert-options-pipeline-processor-to-allow-folders-anywhere"
abstract: "Code example that implements the requirement that allows a user to create folders under any item."
---
# Example: Code for the Insert Options pipeline processor to allow folders anywhere

Use the following Insert Options pipeline processor code to allow a user to create folders under any item.

```csharp
namespace Namespace.Pipelines.GetMasters
{
  public class AllowFolderAnywhere
  {
   public void Process(Sitecore.Pipelines.GetMasters.GetMastersArgs args)
  {
  Sitecore.Data.Items.Item folder = args.Item.Database.Items[Sitecore.TemplateIDs.Folder];
     if(!args.Masters.Contains(folder))
     {
       args.Masters.Add(folder);
     }
   }
  }
 }

```

Add the processor to the insert options pipeline definition after the existing `GetItemMasters` processor and before the existing `GetInsertRules` processor:

```xml
<uiGetMasters argsType="Sitecore.Pipelines.GetMasters.GetMastersArgs">
   <processor mode="on"
type="Sitecore.Pipelines.GetMasters.GetItemMasters,Sitecore.Kernel"/>
    <processor mode="on" type="Namespace.Pipelines.GetMasters.AllowFolderAnywhere,Assembly" />
    <processor mode="on" type="Sitecore.Pipelines.GetMasters.GetInsertRules, Sitecore.Kernel"/>
    <processor mode="on" type="Sitecore.Pipelines.GetMasters.CheckSecurity, Sitecore.Kernel"/>
</uiGetMasters>

```

> [!note]
> You can update this example to incorporate the logic to copy insert options from the parent as described in [Example: Command template code to copy insert options from the parent item](https://doc.sitecore.com/xp/en/developers/103/sitecore-experience-manager/example--command-template-code-to-copy-insert-options-from-the-parent-item.html "Example: Command template code to copy insert options from the parent item").