开发者

Pagination on Propel ORM

开发者 https://www.devze.com 2023-03-05 02:24 出处:网络
i paginated the propel results, its all working fine, but i cant get this thing working. I will really appreciate any help or workaround this issue:

i paginated the propel results, its all working fine, but i cant get this thing working. I will really appreciate any help or workaround this issue:

<?if ($posts->getPage()==???) { ?>
<a href='?p=<?echo end($linkPrevNext);?>'  class="pagNext开发者_开发知识库">next</a>
<?}?>

the function getPage() returns to me the active page, but what should i put on the ??? to hide the last next link on propel, some function like $posts->getLastPage() that actually works. I just cant get any info about this on the Propel documentation.

to hide the first 'previous' link, i used this:

<?if ($posts->getPage()>1) { ?>
<a href='?p=<?echo $linkPrevNext[0];?>'  class="pagPrev">prev</a>
<?}?>


getLastPage() will return the page number of the last page. atLastPage() is a convenience function that will already do the comparison for you, and also exists as atFirstPage(). See the API docs for Propel 1.3, 1.4, 1.5 or 1.6.

You code could look like this:

<?php if (!$posts->atLastPage()) { ?>
<a href='?p=<?php echo $posts->getLastPage(); ?>'  class="pagNext">next</a>
<?php } ?>

I assumed $linkPrevNext contains just the page numbers, like it came from $posts->getNextLinks(). If not, you should not use getLastPage() in the link of course.

0

精彩评论

暂无评论...
验证码 换一张
取 消