Sitecore tips and tricks and community news !

Post Top Ad

Post Top Ad

Dynamic insert options

Insert options, everybody know what does mean :) This is the place where we can make content editor life happier. We can prepare options in Content Editor context menu, to add new item based on some dedicated template.
It looks like image below.

Ok, so we have insert option, we have even put there some our custom template to create datasources. But what if we want to have only one instance of this item in this particular place ? Insert option allows to put as many we can, it doesn't say "Mate, only one is possible here". Is it possible to do that?

Well, yes it is :)

To make this dynamic option, we will use Rule Engine in Sitecore!

1. Rules for Insert Options.

To find rules we have to go to the path:

 /sitecore/system/Settings/Rules/Insert Options/Rules 

 In that place we can find something looks like:

To create new item, just click on Rules parent item and chose "Insert Option Rule". When we create this item, we can go to the field "Rule" and click it. This action will open a dialog when we can build our custom rule.

2. Rules Queries

Rules can as custom as we want. Only constraint can be your imagination. In our case it will be condition, if item (as an instance of our template) has been already added to this particular place, or not. To do that we can write query like:

Voilà, we have dynamic insert option in our application and new friends in content editor team :)

No comments:

Post a Comment