实体内部的 Symfony 分页

Symfony pagination inside in entity

我有实体(比方说 Posts)。 在每个 post 中,我想实现分页("Next" 和 "Previous" 按钮)。

我可以 link 到上一个 post 和下一个。问题是:如果左边没有post,我可以禁用按钮"Previous"(如果你在第一个post,那么应该不可能到达0 post), 得到 post 计数呢? {{ entity | length }} 正在显示当前 post id.

我想要实现的是:当用户在最新的 post 上(假设有 300 个 post),并且在第 300 个 post 上应该禁用 "Next" 按钮(因为此 post 下面没有 post)

P.S。我使用 symfony 2.7 和 Twig 作为模板引擎

我不太明白这个问题,但基于

What I want to achieve is that: when user is on latest post (let's say there are 300 posts), and on the 300-th post there should be disabled "Next" button (because there's no posts below this post)

如果您只想要一个分页器,为什么不使用这个 bundle (KNP)?

Bundle 是 Symfony2 的精髓