A Simple Example

The bean and logic tag libraries used in the following example are standard Apache Struts tag libraries. For information about Struts, see http://struts.apache.org/.

First the required tag libraries are imported, and required publication and section variables are created.

<%@ taglib uri="http://www.escenic.com/taglib/escenic-menu" prefix="MENU" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="BEAN" %>

<BEAN:define id="pub" name="apipublication"
                      type="neo.xredsys.api.Publication" />
<BEAN:define id="sec" name="section"
                      type="neo.xredsys.api.Section" />

A menu object is then retrieved from the current publication and made available as a scripting variable.

<MENU:get id="menu" menuName="main" pubId='<%="" + pub.getId()%>'/>

The value specified with the menuName attribute must be the name of one of the publication's menus, as defined in the Menu Editor. The retrieved menu object is made available as a scripting variable called menu.

The following code iterates over the entries, displaying a link to each section in the menu.

<MENU:iterate id="currentObject" menu="<%=menu%>"
              currentSectionID="<%= sec.getId() %>">
  <MENU:sectionView lang="no" levelName="menu-level">
    <a href='<BEAN:write name="url"/>'><BEAN:write name="text"/></a>
  </MENU:sectionView>
</MENU:iterate>

The iterate tag executes the code in its body once for each menu item. The sectionView tag is therefore executed once for item in the menu, but only actually does anything for menu items of type section. Other tags are available for handling other menu item types:

articleView

For handling article menu items.

urlView

For handling link menu items.

spaceView

For handling space menu items.