14 votes

AttackMonkey Custom Menus

New in Version 2.2:

Updated the package so that it now workjs with newer vewrsions of 7. This fixes the issue where the menu items weren't rendering correctly, and the actions weren't firing right.

New in Version 2.1:

Updated so that you can target media/content root nodes and remove menu items. To target a root node, set the node id to "-1" and the DocType Alias to eith "media" or "content", and then set the remove menu items as normal.

New in Version 2.0:

Updated for v7!!! This version will not work in earlier versions, for v4/6, use version 1.5. No new features, just ports existing functionality to the v7 API and Angular back office.

New in Version 1.5:

Fixes and issue where create and delete were being set to RelationType instead of content in newer versions of Umbraco.

New in Version 1.4:

Fixes an issue where create and delete weren't getting removed from menus if they were set in removeMenuItems on 4.11+.

New in Version 1.3:

Minor performance tweaks, addition of custom method which allows you to apply the rules to your own menu nodes if required (say if you were building your own tree).

New in Version 1.2:

You can now set context menu items to be removed, by specifying a comma separated list of menu items to remove in a property called "removeMenuItems" in the config file (see included config file for example). Note: If you have normal "menuItems" rules, those cause ALL items to be removed first, which means you don't need to set the "removeItems" property.

To update, just replace the old DLL with the one from the new package and you're good to go, no other changes required.

New in Version 1.1:

You can now make it so that members of the administrator group see the "normal" menus instead of your custom ones, by setting the new config value "ignoreForAdmin" to "true".

You can also make the rules be applied to the media section as well, by setting the new config value "useInMediaSection" to "true".

If you are updating from a previous version, just replace the DLL and add the two new values to the customMenus.config file (see the example config in the package for the defaults).

--------------

It's quite a common practice to set up a "settings" area in your back office in Umbraco. This is a set of nodes that contain site settings for things like copyright notices, rotating images for homepages and the like. These are just for admin purposes and are not displayed on the front end.

The last thing you want is to get a call from a client saying "errr, you know that settings section, I kinda deleted it. And emptied the recycle bin". Noooooo! You could set the node permissions for individual users, but you have to do it each time a new user is added. You could also code a custom event handler that would remove the menu items based on nodeId/DocType. But what if you can't code C#, or you just don't wanna?

This package allows you to set up rules to override the default menus on nodes within the content tree, based on either docType or node id. Using this package its possible to:

  • Remove all menu items from certain nodes
  • Only have certain menu items for certain nodes
  • Overide the click action for the node (so they can't edit the properties for example)
The package is pretty simple, just a DLL and a config file that allows you to set up the rules. The package will also respect any permissions that you've already defined on nodes, so if you have a user who can't delete a node and you assign the delete menu item with this package, they still won't be able to delete the node!


The config file is pretty straightforward, it's called "customMenus.config" and can be found in the config folder of your Umbraco site after installation. The file has some basic rules examples and a syntax guide at the top of the file to help you write your rules.
Basically, each rule consists of the following properties:
  • docTypeAlias - this is a case sensitive docType alias of the document type that you want the rule to affect, you can leavethis blank if you want to target a node id instead
  • nodeId - this is the numerica id of the node that you want to target with the rule, if you are using docTypeAlias, leave this blank
  • clickAction - you can override the click action of the node here, say for example you don't want the usr to see the edit page for the node, you could just put a link to the content dashboard here (javascript:UmbClientMgr.appActions().openDashboard('content'); in 4.7).
  • menuItems - a case sensitive, comma separated list of the menu items that you want to display for the node (see menu reference below), if you leave this blank, there will be no menu options displayed for the node
You can add as many rules as you like, although the more rules you have, the more potential impact on performance. I've tested this with up to 20 rules with no noticeable performance impact.


The package will pick up ANY menu item action that's been installed on your copy of Umbraco, so it should pick up custom actions that have been installed as well. Obviously, not all actions are relevant to content, so I've listed the common content related menu items here for reference:
  • assignDomain - assign host name
  • auditTrail - view audit trail
  • browse - browe node
  • copy - copy node
  • delete - delete node
  • emptyTrashcan - empty recycle bin
  • liveEdit - live editor link
  • move - move content
  • create - create new content
  • notify - notification link
  • protect - member authentication link
  • publish - publish page
  • refreshNode - reload nodes
  • rights - set admin user permissions list
  • rollback - rollback link
  • sendToTranslate - send to translation link
  • sort - sort documents
  • sendtopublish - send to publis
  • translate - translate link
  • unpublish - unpublish page
  • separator - menu divider
Changes to the config should be picked up in real time, so need to restart the app pool once the changes are made. You WILL have to reload the content tree to see changes if you've previously been in the content section, as Umbraco caches the tree when you switch sections.


One thing to watch out for, this extension makes a few calls to database intensive methods, so use with caution on site with large lists of nodes under a single node. If you run into problems, you can remove the package by deleting the DLL and config file from the site. The package also requires .NET 4.0 in order to run!


Please vote for this project if you like it!

Package owner

Tim

Tim

Tim has 2638 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
8.0.x (untested)
7.14.x (untested)
7.13.x (untested)
7.12.x (untested)
7.11.x (untested)
7.10.x (untested)
7.9.x (untested)
7.8.x (untested)
7.7.x (untested)
7.6.x (untested)
7.5.x (untested)
7.4.x (untested)
7.3.x (100%)
7.2.x (100%)
7.1.x (100%)
7.0.x (100%)
6.1.x (untested)
6.0.x (100%)

You must login before you can report on package compatibility.

Package Information

  • Package owner: Tim
  • Created: 13/04/2011
  • Current version 2.2
  • .net Version 4.0,4.5
  • License MIT
  • Downloads: 4561

External resources