Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jammykam/Konabos.SharedSource.MenuItemRules

Rules-based Context Item Menu Visibility
https://github.com/jammykam/Konabos.SharedSource.MenuItemRules

Last synced: 3 months ago
JSON representation

Rules-based Context Item Menu Visibility

Awesome Lists containing this project

README

        

# Konabos.SharedSource.MenuItemRules
## Rules-based Context Item Menu Visibility

1. Add a new class and create a command, inheriting from `Konabos.CMS.MenuItemRules.Command.RulesBasedMenuCommand` and implement the `Execute` method.

```csharp
using Konabos.CMS.MenuItemRules.Command;
using Sitecore.Shell.Framework.Commands;

namespace Konabos.CMS.MenuItemRules
{
public class MenuCustom : RulesBasedMenuCommand
{
public override void Execute(CommandContext context)
{
throw new NotImplementedException();
}
}
}
```

2. Register the command in config, for example:

```xml






```

3. Create the menu item in the `Core` database under: `/sitecore/content/Applications/Content Editor/Context Menues/Default`. Set the **Message** field to your command, e.g. `menu:custom(id=$Target)`

4. Create a `Rule` under `/sitecore/system/Settings/Rules/Context Menu Items/Rules` in the master database. The Rule name should match the sanitized command name which does not include any invalid item name characters. Using the above as an example: **menucustom** and **menuanother**.

5. Edit the rule, set your Conditions and then set the Action to **"set the command state to enabled"** in order to make the menu item visible.

![Add Menu Visiblity Rules](https://github.com/jammykam/Konabos.SharedSource.MenuItemRules/raw/master/screenshots/Edit%20Menu%20Visibility%20Rules.png "Add Menu Visiblity Rules")

If you want to integrate the code into your own project - the items have been serialized or there is a TDS project or there is an items-only package. You need to update the `Type` field in **/sitecore/system/Settings/Rules/Definitions/Elements/Context Menu Rules/Set Command State** in master database.