Skip to content
OpenCms documentation
OpenCms documentation

Adding a context menu item

This example demonstrates how to add a new menu item to the OpenCms explorer's context menu.

You can view the source code of this example here:

The example generates a new main menu item "Greet" with a subitem "Say Hello". Clicking on the sub-item you get an alert message, saying hello.

The visibility of the menu items is as follows:

  • For folders the item does not show up
  • For multiple resources, the item shows up, but is deactivated
  • For a single non-folder resource the item shows up and is active

This is illustrated by the following figures.

For folders the 'Greet' item does not appear
For all resources that are no folder, the 'Greet' item appears with active sub-item 'Say hello'
For more than one resource, the 'Greet' item appears, but 'Say Hello' is deactivated.
When clicking 'Say Hello' an alert box shows up, greeting the currently active user