Code Part
Create a base command
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Shell.Framework.Commands;
namespace Feature.CommandTemplate.Commands
{
    public abstract class CommandBase : Command
    {
        public override CommandState QueryState(CommandContext context)
        {
            Assert.ArgumentNotNull((object)context, nameof(context));
            Item[] items = context.Items;
            if (items.Length != 1)
                return CommandState.Hidden;
            Item obj = items[0];
            return CommandState.Enabled;
        }
    }
}
Implement our command template
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Shell.Framework.Commands;
using Sitecore.Web.UI.Sheer;
using System;
namespace Feature.CommandTemplate.Commands
{
    public class SampleCommand : CommandBase
    {
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, nameof(context));
            if (context.Items.Length < 1)
            {
                return;
            }
            Item obj = context.Items[0];
            Sitecore.Context.ClientPage.Start("sample.ui");
        }
    }
}
You can start your processor, I have used the sample.ui as the processor name.
Add your configuration
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
    <sitecore>
        <commands>
            <command name="sitecoreshades:ribbon:sample" type="Feature.CommandTemplate.Commands.SampleCommand, Feature.CommandTemplate" />
        </commands>
    </sitecore>
</configuration>
 
 
No comments:
Post a Comment