Sitecore Insert Options Rules

Posted 25 November 2015 by Marek Musielak

sitecore insert option rules

One of the first things explained to Sitecore Developers during the certification courses are Sitecore Insert Options. Everyone knows them. Configure -> Assign and it's all set. However not many people have ever heard about or used Insert Options Rules.

Lets consider a standard scenario when we want to keep a number of Video items inside Sitecore tree under the Data/Videos item. We also want to allow authors to group videos in folders. Simple solution using Insert Options?

  1. Create a new template called Video Folder
  2. Create Standard Values item for Video Folder
  3. Set Insert Options on Standard Values item to allow only either Video Folder or Video items to be created under Video Folder items.

Simple? Sure, everyone knows that.

Same thing can be achieved without creating new template. First create Videos item using standard Folder template. Then find /sitecore/system/Settings/Rules/Insert Options/Rules item and create new item under that node using Insert Options Rule template. Now edit the rule and set it to:

where the item is the Videos item or one of its descendants
    and where the parent template is Folder
add Video insert option

sitecore insert option rules - simple rule

That's it. You don't need to do anything else. Authors will be able to add only Folder or Video items under the Videos item. But what have we gained? We have single rule item instead of a new template and its Standard Values. True, we can still add more rules inside single Insert Options Rules item, but it's still not that much. Answer for this question comes when we consider just a little bit more complex scenario.

Lets think about same scenario as above, but the additional requirement is that we don't want users to create too many levels of folders under the Videos node. We want to limit the subfolder levels number to 2. We can have Videos/Cars/Ford folder and all Ford videos under it, but we don't want to split them into smaller groups by creating e.g. Videos/Cars/Ford/Mustang folder. If we want to achieve this using only Insert Options, we would have to create a Video Subfolder template and Video Subsubfolder template and allow first of them under the Videos node and the second of them under the first one. Doable, but we start to overcomplicate things.

With Insert Option Rules it is much simpler. We add another rule to our item and we set it to:

where the item is the Videos item or one of its descendants
    and where the level of the item is greater than or equal to 6
remove Folder insert option

sitecore insert option rules - advanced rule

And it all works. No need for new templates. And if we decide in the future that we want to allow 3rd level of folders or we change our mind and we decide that even 2 levels are too much and we want only one level, we don't have to create or remove templates and do changes in multiple places - it's all there in one place - in Sitecore Insert Options Rules.


That was only a simple example showing only small part of Insert Options Rules capabilities. If you've ever worked with Sitecore Rules Enginge, I'm quite sure you can see how powerful Sitecore Insert Options Rules can be comparing to Insert Options set on items.