#1 caoge
speedPHP里使用spPager($page,$size)->findAll(),当$size大等于数据库里的记录时,spPager()->getPager()获取的分页数据就是空的?能不能也获取到总共有几条记录?2011-05-11 21:42:56
2011-05-11 21:42:56
2011-05-11 22:43:06
#4 jake
把{if $pager}这块的判断,放到{if $comments!=''}的{else}之前,这样子没有评论的时候,不显示任何分页。
然后根据上面代码,{if $pager}和它的{else},的确是按你所想的“只有一页数据的时候,也显示分页”2011-05-12 07:19:24
{if $comments!=''}
{section name=id loop=$comments}
{$smarty.section.id.rownum}、{$comments[id].user_name} 发表于:{$comments[id].create_time|date_format:" %Y-%m-%d %H:%M:%S"}
{$comments[id].contents}
{if $comments[id].reply!=''}
博主回复:{$comments[id].reply}
{/if}
{/section}
{else}
暂无评论
{/if}
{if $pager}
首页
{foreach from=$pager.all_pages item=thepage}
{if $thepage!=$pager.current_page}
{$thepage}
{else}
{$thepage}
{/if}
{/foreach}
末页
{else}
首页
1
末页
{/if}如果数据库有记录的时候分页不是空的话,不会出现上面的问题,
或者加个判断语句,count下数据库记录,等于0就不显示分页也行。其实没什么大的影响,个人一点想法,老大见笑了O(∩_∩)O~
2011-05-11 23:58:23