Has anyone implemented a feature like Reversed Insert Options? Meaning a template should know where it should be added as an Insert Option rather than what it can add?
-
1Have you tried Sitecore Insert Options Rules skillcore.net/sitecore/sitecore-insert-options-rules ?– Marek Musielak ♦Commented Jun 22, 2018 at 6:04
-
No but inthink with this approach if you add new templates or feature with template you have to add rules. I would extend the current implementation. Wondering if anyone did something like that so i dont have to :)– alinulmsCommented Jun 22, 2018 at 6:17
1 Answer
You can implement such a functionality in next way:
- Create a base template with a field Revert Insert Options. The type of the field is TreeListEx and datasource will be:
DataSource=/sitecore/templates&IncludeTemplatesForSelection=Template,Branch,Command Template&IncludeTemplatesForDisplay=Branch folder,Branch,Template folder,Template,Folder,Node,Main section,Command Template&ExcludeItemsForDisplay={0DE95AE4-41AB-4D01-9EB0-67441B7C2450},{EB2E4FFD-2761-4653-B052-26A64D385227},{3D6658D8-A0BF-4E75-B3E2-D050FABCF4E1},{13D6D6C6-C50B-4BBD-B331-2B04F1A58F21}
This is the datasource for insert options field, you will have something similar.
All your new templates will inherit from this base template.
Create an event and add it to item:saved events.
In this event you will implement next functionality:
a) Verify if the saved event was trigger on a template.
b) Verify if the Revert Insert Options field has templates selected. If it has parse the templates.
c) Check if the selected templates has Standard Values. If it doesn't exist create Standard Values programatically.
d) Add in the __Masters field (this field is responsable for insert option) the template from step "a"
-
This is the approach you would take if you would extend the Assign functionality on template I guess. And you need to implement this once.– alinulmsCommented Jun 22, 2018 at 6:32