smarty分页程序,模板小改进
07-27
增加了:跳转到第几页的功能
模板部分
- <div id="page">
- <table>
- <tr>
- <td>
- 共{{$page.count}}条数据 每页{{$page.pagesize}}条 共{{$page.pagecount}}页 当前第{{$page.page}}页
- <!-- 新加的跳转功能 start -->
- 跳转到第
- <select onchange="window.location.href='{{$page.baseurl}}&page='+this.options[this.selectedIndex].value">
- {{section name=pagejump loop=4 start=0 step=1 max=4}}
- <option value="{{$smarty.section.pagejump.index+1}}">{{$smarty.section.pagejump.index+1}}</option>
- {{/section}}
- </select> 页
- <!-- 新加的跳转功能 start -->
- </td>
- <td>
- {{if $page.pagecount>1}}
- {{if $page.first eq 1}}
- <a href="{{$page.baseurl}}">首页</a>
- {{else}}
- 首页
- {{/if}}
- {{if $page.pre eq 1}}
- <a href="{{$page.baseurl}}&page={{$page.page-1}}">上一页</a>
- {{else}}
- 上一页
- {{/if}}
- {{foreach from=$page.pagelist item=vols}}
- {{if ($vols.page > 0 ) && ($vols.page < = $page.pagecount) }}
- {{if $vols.link eq 1}}
- <a href="{{$page.baseurl}}&page={{$vols.page}}">[{{$vols.page}}]
- {{else}}
- [{{$vols.page}}]
- {{/if}}
- {{/if}}
- {{/foreach}}
- {{if $page.next eq 1}}
- <a href="{{$page.baseurl|default:"?"}}&page={{$page.page+1}}">下一页</a>
- {{else}}
- 下一页
- {{/if}}
- {{if $page.last eq 1}}
- <a href="{{$page.baseurl|default:"?"}}&page={{$page.pagecount}}">尾页</a>
- {{else}}
- 尾页
- {{/if}}
- {{/if}}
- </td>
- </tr>
- </table>
- </div>
其实我在做的时候又出现个问题,如果是url重写了,如何来做这个baseurl变量。问题解决方法是,把url当做模板,比如/blog/index/%d

