WebSphere Portal中多层Placebar主题的开发(二)

示例效果如图:
代码:
<%@ 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>
      <!-- 显示系统时间 --> 
       &nbsp;&nbsp;<wps:text key="today" bundle="nls.theme"/>&nbsp;<%=nYear%>&nbsp;年&nbsp;<wps:text key="year" bundle="nls.theme"/><%=nMonth+1 %>&nbsp;月&nbsp;<wps:text key="month" bundle="nls.theme"/><%=nDate %>&nbsp;日<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" />' >
        &nbsp;<%= com.ibm.wps.model.LocaleHelper.getTitle((com.ibm.portal.Localized)wpsNavNode, pageContext.getRequest()) %>&nbsp;
       </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" />' >
        &nbsp;<%= com.ibm.wps.model.LocaleHelper.getTitle((com.ibm.portal.Localized)wpsNavNode, pageContext.getRequest()) %>&nbsp;
       </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值,使上下能够对齐。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值