+

Search Tips   |   Advanced Search

Customize Person card actions through the theme


We can use the theme to add items to the Person card's More actions menu in any portlet that uses the AJAX person tag.

  1. Locate the theme file which contains the <body></body> tags of the page. This is most often Default.jsp, or theme.html. For more information on locating the theme's files, see Location of theme resources.

  2. Open the file in a text editor.

  3. To add a menu item, add XML code to the end of the file, just before </body></html> tags. The following sample code adds a menu item called Test Action.
    <div class="com.ibm.portal.action" style="display:none;">
     <span class="action-id">test.action1</span>
     <span class="action-impl">/javascript/TestAction.js</span>
     <span class="action-context">person</span>
     <span class="action-label">Test Action</span>
     <span class="action-description">This is a test for extending Person menu</span>
     <span class="action-showif">TestAction.showif</span>
     <span class="action-url">javascript:TestAction.execute(@@@ARGS@@@)</span>
     <span class="action-order">0</span>
    </div>
    

  4. Save the changes to the file.

  5. Create a JavaScript file that executes the action to occur when the associated menu item is selected. The following sample code generates an alert when the menu item Test Action is selected.
    var TestAction = {
      showif: function(person) {
        return true;
      },   execute: function(person) {
        alert("TestAction executed for: " + person.fn);
      }
    }
    

    Paste the JavaScript file (TestAction.js) in a directory where it can be accessed by a URL.

    For example we could put the TestAction.js file in either a javascript directory in the root of the web server (/javascript/TestAction.js) or a directory in the theme WAR file /yourthemecontext/javascript/TestAction.js.

  6. If the file you modified in step 1 was not Default.jsp, update the file's timestamp by making a change, removing the change, and then saving the file.

  7. To verify the new action was added, open a portlet that supports people awareness (for example, the People Finder) and then view the Person card for a selected user. Verify the option we added (for example Test Action) is available from the More actions menu and that it works as expected.


Parent: Collaborative Services API