Customizing the Control Menu

Liferay’s Control Menu consists of three main sections: Sites (left portion), Tools (middle portion), and User (right portion).

Figure 1: This image shows where your entry will reside depending on the category you select.

Figure 1: This image shows where your entry will reside depending on the category you select.

You can reference a sample Control Menu Entry by visiting the Control Menu Entry article.

ProductNavigationControlMenuEntry Interface

To create a control menu entry, you must implement the ProductNavigationControlMenuEntry interface. It’s recommended to implement this interface by extending the BaseProductNavigationControlMenuEntry or BaseJSPProductNavigationControlMenuEntry abstract classes.

These base classes are covered in more detail next.

BaseProductNavigationControlMenuEntry

Typically, the BaseProductNavigationControlMenuEntry is extended for basic entries that only display a link with text or a simple icon. If you want to provide a more complex UI with buttons or a sub-menu, you can override the include() and includeBody() methods.

The IndexingProductNavigationControlMenuEntry is a simple example for providing text and an icon. It extends the BaseProductNavigationControlMenuEntry class and is used when Liferay is indexing. The indexing entry is displayed in the Tools (middle) area of the Control Menu with a Refresh icon and text stating The Portal is currently indexing.

BaseJSPProductNavigationControlMenuEntry

If you use JSPs for generating the UI, you can extend BaseJSPProductNavigationControlMenuEntry to save time when creating/modifying a control menu entry.

The ProductMenuProductNavigationControlMenuEntry creates an entry that appears in the Sites (left) area of the Control Menu. This class extends the BaseJSPProductNavigationControlMenuEntry class. This provides several more methods that use JSPs to define your entry’s UI. There are two methods to notice:

@Override
public String getBodyJspPath() {
return "/portlet/control_menu/product_menu_control_menu_entry_body.jsp";
}

@Override
public String getIconJspPath() {
return "/portlet/control_menu/product_menu_control_menu_entry_icon.jsp";
}

The getIconJspPath() method provides the Product Menu icon (Menu ClosedMenu Open), and the getBodyJspPath() method adds the UI body for the entry outside of the Control Menu. The latter method must be used when providing a UI outside the Control Menu. You can test this by opening and closing the Product Menu on the home page.

Finally, if you provide functionality that is exclusively inside the Control Menu, the StagingProductNavigationControlMenuEntry class calls its JSP like this:

@Override
public String getIconJspPath() {
return "/control_menu/entry.jsp";
}

The entry.jsp is returned, which embeds the Staging Bar portlet into the Control Menu.

Next, you’ll step through the process of customizing the Control Menu.

« Adding Custom Panel AppsCreating Control Menu Entries »
この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています