六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 265|回复: 0

发布一个freemarker仿discuz分页标签的marco

[复制链接]

升级  6.67%

14

主题

14

主题

14

主题

秀才

Rank: 2

积分
60
 楼主| 发表于 2013-2-8 00:58:40 | 显示全部楼层 |阅读模式
<#macro page_table>
<table cellpadding="0" cellspacing="0" border="0" class="pageTable">
<tr>
   <td align="left" width="*">
    <#nested />
   </td>
   <td align="right" width="100">
     
   </td>
</tr>
</table>
</#macro>

<#macro page_nav actionUrl page param extra...>
<#assign end=(actionUrl?index_of(".action")) />
<#assign actionName>${actionUrl?substring(0,end)}</#assign>

<form id="${actionName}" name="${actionName}" method="post" action="${actionUrl}">
<input type="hidden" id="pageNo" name="${param}.pageNo" value="" />
<#list extra?keys as attr>
   <input type="hidden" name="${attr}" value="${extra[attr]}" />
</#list>
<table border="0" align="left" cellpadding="0" cellspacing="0" width="auto">
   <tr>
    <td class="pagination">
     <div class="pagination_totalCount">第${page.pageNo}页</div>
     <#if (page.pageNo gt 1) >
      <div class="pagination_index" >
       <span class="arrow"><<</span>
      </div>
     </#if>
   
     <#if (page.pageNo gt 9)>
      <#assign starPage=(page.pageNo - 4) />
      <#if ((page.totalPages - page.pageNo)>4)>
       <#assign endPage=(page.pageNo + 4) />
      <#else>
       <#assign endPage=page.totalPages />
      </#if>
     <#elseif (page.totalPages lt 10)>
      <#assign starPage=1 />
      <#assign endPage=page.totalPages />
     <#else>
      <#assign starPage=1 />
      <#assign endPage=10 />
     </#if>
   
     <#list starPage..endPage as i>   
      <#if i == page.pageNo>
       <div class="pagination_curr" >${i}</div>
      <#else>
       <div class="pagination_index" >${i}</div>
      </#if>
     </#list>
   
     <#if (page.pageNo lt page.totalPages) >
      <div class="pagination_index" >
       <span class="arrow">>></span>
      </div>
     </#if>
     <div class="pagination_totalCount">共${page.totalPages}页,${page.totalCount}条记录</div>
    </td>
   </tr>
</table>
</form>
</#macro>

=============

对应css样式

=============

.pagination
{
color: #878787;border: 1px solid #D9D9D4; background: #f7f7f7;cursor: pointer;
height: 20px !important;height: 24px;padding:0px;
}
.pagination_curr
{
color: red;float: left;text-align: center;line-height: 150%;
width: 20px;height: 100%;font-size: 14px;background-color: #ccc;
}
.pagination_index
{
color: black;float: left;text-align: center;
width: 20px;height: 100%;font-size: 14px;line-height: 150%;
}
.pagination_totalCount
{
font-size: 12px;color: black;float: left;text-align: center;line-height: 150%;
padding-top: 2px;padding-left: 5px;padding-right: 5px;
width: auto;height: 18px !important;height: 22px;
}
.paginationLine
{
margin-top:5px;text-align: right;
}
.arrow
{
font-size: 10px;
}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表