Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/jammykam/Konabos.SharedSource.MenuItemRules
- Owner: jammykam
- Created: 2017-10-04T01:21:48.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-04T01:29:53.000Z (about 7 years ago)
- Last Synced: 2024-01-25T03:04:19.532Z (10 months ago)
- Language: C#
- Homepage: HomePage
- Size: 301 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- Awesome-Sitecore - MenuItemRules - Rules-based context item menu visibility. (Rules)
README
# Konabos.SharedSource.MenuItemRules
## Rules-based Context Item Menu Visibility1. 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.