We have created a ribbon in Sitecore that have few command buttons and few PowersSell command buttons.

We want them to be visible only when an author hits specific items in the Content Editor. So we tried to hide both types of command buttons using the QueryState method as shown below:

public override CommandState QueryState(CommandContext context)
    Item contextItem = context.Items[0];
    if (contextItem.TeamplateName=="specific_template")
        return CommandState.Enabled;
    return CommandState.Hidden;

It hides the normal command buttons but not the PowerShell command buttons.

So we would like to hide the entire ribbon itself so that none of the commands can appear in the Content Editor menu.

Has someone ran into this situation and know how to hide the ribbon or hide the PowerShell command button?

2 Answers 2


You can use Sitecore Contextual Ribbon to do the above task. You will not require to do any code implementation.

You need to create the ribbon in Core database at the path /sitecore/content/Applications/Content Editor/Ribbons/Contextual Ribbons.

Then, from the master database, navigates to the item template where you want the ribbon to appear and search for the Ribbon in the Standard Fields. Select your contextual ribbon from the droptree.

enter image description here

The ribbon will only appear when the user clicks on an item which is derived from the template you set the ribbon.


You did not specifically call this out, but I thought I would point it out to you in case it simplifies what you are trying to achieve.

If you decide to use an existing ribbon, such as the Developer ribbon, you can rely on the rules for the script.

Read more about it here.

Example: The following script displays whenever there is an item with one of two fields empty.


The Show Rule determines when the button should appear. The Enable Rule determines when the button should be enabled.



If the ribbon is controlled by SPE, then when all buttons are hidden then so will the ribbon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.