In my example, Sitecore PowerShell Extensions (SPE) patches the command in order to provide insert options.
Reviewing the ShowConfig.aspx I see the following:
<command name="item:new" type="Cognifide.PowerShell.Client.Commands.MenuItems.ItemNew, Cognifide.PowerShell" patch:source="Cognifide.PowerShell.config"/>
My concern is that when I patch over the same command name SPE will break.
Is there a way to support multiple command implementations? Perhaps this would make a great module!
Update 1
Based on Mark's feedback I came up with this quick script to determine what might be possible. The script just queries the items that are already in the list. Perhaps I could use this to determine if I should add more items to the list. Also, not sure how I could add my own dividers.
$commandName = "item:new"
$item = Get-Item -Path "master:" -ID "{A3572733-5062-43E9-A447-54698BC1C637}"
$commandContext = New-Object -TypeName Sitecore.Shell.Framework.Commands.CommandContext -ArgumentList $item
[Sitecore.Shell.Framework.Commands.CommandManager]::GetCommand($commandName).GetSubMenuItems($commandContext) |
Where-Object { $_.GetType().Name -eq 'MenuItem' } | Select-Object -Property header
Here's what I think might work.
- Create a new insert options with condition and action to render the desired items.
- Figure out what happens when the user click the insert option.
Update 2
I found a solution by writing a module for it. See the answer below.