示例效果如图:
代码:
<%@ 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 firstNum = 10; //首行的栏目数为firstNum
int cNum=12; //从第二行开始每行的栏目数为cNum
int temp;
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>
<table height=30 width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="tdDate" class="wpsPlaceBar1" align=center valign=middle width=197 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>
<%
temp = i - firstNum;
if ( i == firstNum ) {
%>
<td class="wpsUnSelectedPlace" nowrap></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- 需要调整width,选取合适值才可保证上下对齐 -->
<td class="wpsUnSelectedPlace" height=30 width=60></td>
<%
} else if ( temp % cNum == 0 ) {
%>
<td class="wpsUnSelectedPlace" nowrap></td>
</tr>
<tr>
<td class="wpsUnSelectedPlace" height=30></td>
<%
}
i++;
%>
<wps:if nodeInSelectionPath="no">
<td align=center valign=middle class="wpsUnSelectedPlace" 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 align=center valign=middle class="wpsSelectedPlace" 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>
</td>
</tr>
</table>
</wps:if>
注释:
firstNum控制首行的栏目数。
cNum控制从第二行开始每行的栏目数,建议比第一行多加两栏即可。
另外还需调整代码中<td class="wpsUnSelectedPlace" height=30 width=64></td>一行中的width值,使上下能够对齐。