Is there any way to grey out the content editor archive button for all Sitecore items for every user It should look like this
-
Are you asking about disabling the permissions so that users cannot use that button?– Jason St-CyrCommented Nov 6, 2023 at 12:19
-
yes, but as per requirement, the button should be visible as shown in attached screenshot– Sanjay KumarCommented Nov 6, 2023 at 12:27
-
1You could deny the permission for a basic role for these items in the core database.– Vinay JadavCommented Nov 6, 2023 at 15:48
-
I think you want these buttons to be disabled but yet to be visible to content authors. Is that correct?– GhanCommented Nov 7, 2023 at 17:13
2 Answers
This is the solution that worked for me
- Create a Custom Command: Create a new class that inherits from Sitecore.Shell.Framework.Commands.Command and implement the necessary logic for your button.
using Sitecore.Shell.Framework.Commands; public class MyCustomCommand : Command { public override void Execute(CommandContext context) { // Your custom logic here } public override CommandState QueryState(CommandContext context) { return CommandState.Disabled; } }
- Configure the Command in Sitecore: Create an XML configuration file in your Sitecore solution, e.g., MyCustomCommand.config, to define your command. Place this file in the App_Config\Include folder.
<?xml version="1.0" encoding="utf-8" ?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <commands> <command name="mycustomcommand" type="YourNamespace.MyCustomCommand, YourAssembly" /> </commands> </sitecore> </configuration>
- Add command to your button
To visually "grey out" a ribbon item, you can use custom CSS. You can apply CSS styles to make it appear disabled.
I checked the html element for the ribbon chunk you mentioned in Sitecore 9.3 and SC 10.3.1 and it seems that you can hide it using the CSS
.chunk#CE42470D6C6FC4F618BF7D87CC7A95659 {
opacity: 0.5;
pointer-events: none;
}
You can add this CSS in {webroot}/sitecore/shell/themes/standard/default/Ribbon.css
or can create a custom CSS file for the same
Hope this helps!