示例效果如图:
代码:
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="com.ibm.wps.portlets.admin.shared.*"%>
<%@ page import="com.ibm.portal.content.ContentNode" %>
<%@ page import="com.ibm.portal.content.ContentNodeType" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%
int i = 0;
int cNum = 10; //每行的栏目数为cNum
Calendar currDate = Calendar.getInstance();
int nYear = currDate.get(Calendar.YEAR);
int nMonth = currDate.get(Calendar.MONTH);
int nDate = currDate.get(Calendar.DATE);
int nDay = currDate.get(Calendar.DAY_OF_WEEK);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
%>
<wps:if navigationAvailable="yes" screen="Home,LoggedIn,LoggedOut">
<!-- one row, one cell table to span the page-->
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td id="tdDate" class="wpsPlaceBar1" height=30 align=center valign=middle width=200 style="font-variant:small-caps" nowrap>
<!-- 显示系统时间 -->
<wps:text key="today" bundle="nls.theme"/> <%=nYear%> 年 <wps:text key="year" bundle="nls.theme"/><%=nMonth+1 %> 月 <wps:text key="month" bundle="nls.theme"/><%=nDate %> 日<wps:text key="date" bundle="nls.theme"/>
</td>
<td width=22 class="wpsPlaceBar2" >
</td>
<wps:navigation startLevel="2" stopLevel="2">
<wps:navigationLoop>
<%
if ( (i % cNum == 0) && (i != 0) ) {
%>
</tr>
<tr>
<td class="wpsUnSelectedPlace" height=30></td>
<td class="wpsUnSelectedPlace"></td>
<%
}
i++;
%>
<wps:if nodeInSelectionPath="no">
<td class="wpsUnSelectedPlace" nowrap width=70>
<a class="wpsUnSelectedPlaceLink" href='<wps:navigationUrl type="link" />' >
<%= com.ibm.wps.model.LocaleHelper.getTitle((com.ibm.portal.Localized)wpsNavNode, pageContext.getRequest()) %>
</a>
</td>
</wps:if>
<wps:if nodeInSelectionPath="yes">
<td class="wpsSelectedPlace" nowrap width=70>
<a class="wpsSelectedPlaceLink" href='<wps:navigationUrl type="link" />' >
<%= com.ibm.wps.model.LocaleHelper.getTitle((com.ibm.portal.Localized)wpsNavNode, pageContext.getRequest())%>
</a>
</td>
</wps:if>
<td width=1><img src='<wps:urlFindInTheme file="njtc_images/placebar_sp.gif"/>'/></td>
</wps:navigationLoop>
</wps:navigation>
<td class="wpsUnSelectedPlace" nowrap colspan=100></td>
</tr>
</table>
</wps:if>
注释:
cNum变量控制每行显示的栏目数。
标签<wps:navigation startLevel="2" stopLevel="2">指定有几层栏目。
<wps:navigationLoop>是一个循环,依次读取所有placebar上要显示的栏目,
<wps:if nodeInSelectionPath="no">判断是否是选中栏目,no表示未选中,yes选中,据此赋予对应的样式。