+

Search Tips   |   Advanced Search

Dynamically extending an existing menu item from a module

Use a module to add menu items to a menu where the menu item displays only on certain pages,

  1. Define the module as a JSON file or as part of a plugin.xml file.

    If we define it as a JSON file, put this file in WebDAV at...

      fs-type1/themes/myTheme/contributions/

    If we define it as a plugin.xml system module, put it in the application .war file in the WEB-INF directory.

    • Define the override module as a JSON file.
        {
        "modules":[{
          "id":"menuModule",   "contributions":[{
           "type":"menu",    "sub-contributions":[{
            "type":"json", "ref-id":"pageAction", "uris":[{
             "value":"/menuTest/menuItem.json"
            }]
           }]
          }]
         }]
        }
        

        ref-id

        The reference ID of the menu to use - this example uses the Action menu for the page.

        value

        A pointer to the file that includes the menu item specifications - this example points to a path relative to your theme location.

    • Define the override module in a plugin.xml file.
        <extension point="com.ibm.portal.resourceaggregator.module"  >
            <module >
                <contribution type="config">
                 <sub-contribution type="config_dynamic" ref->
                 <uri value="res://wps/defaultTheme80/themes/html/menuTest/menuAction.jsp" />           </sub-contribution>
                </contribution>
                 <contribution type="menu">
                 <sub-contribution type="json" ref->
                 <uri value="res://wps/defaultTheme80/themes/html/menuTest/menuItem.json" />           </sub-contribution>
                </contribution>
            </module>  </extension>
        

        extension id

        Any meaningful ID.

        module id

        Any meaningful ID.

        sub-contribution ref-id

        The reference ID of the menu to use, this example uses the Action menu for the page.

        uri value

        A pointer to the files is required to create the menu or other content. In the previous example, there are two contribution types listed. For the menu contribution and its json subcontribution, this example shows the uri points to a JSON format file within the theme that defines one or more menu items in the JSON menu definition file syntax.

  2. Create the menuitem.json defined in step 1.

    See Server-side framework - Simple menu.

  3. Include the override module in a profile. For example, in profile_menuModule.json:
      {
       "moduleIDs": [
        "menuModule",   ...
      

    The profile_menuModule.json file must be copied to WebDAV at fs-type1/themes/myTheme/profiles/.

  4. Open the desired menu json and add an entry for the module to the menu. Use the following example.
      {
      "type":"ModuleRef", "id":"menuModule"
      }  


Parent Writing modules

Related concepts:

Server-side framework - Simple menu