# Prev/next pagination url in controller from a PaginatedResultSet

**URL:** <https://discourse.cakephp.org/t/prev-next-pagination-url-in-controller-from-a-paginatedresultset/12965>\
**Category:** Need Help\
**Created:** [September 16, 2026, 11:17pm UTC](https://discourse.cakephp.org/t/prev-next-pagination-url-in-controller-from-a-paginatedresultset/12965 "2026-09-16T23:17:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erwane](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/erwane/32/3253_2.png) [@Erwane](https://discourse.cakephp.org/u/Erwane)\
**Post date:** [September 16, 2026, 11:17pm UTC](https://discourse.cakephp.org/t/prev-next-pagination-url-in-controller-from-a-paginatedresultset/12965/1 "2026-09-16T23:17:50Z")

</div>

Hi,

Cakephp: 5.4  
PHP: 8.5  
View: Twig

With TwigView, lots of view things should be moved to controller.  
StructuredData as LD+json format is build in the controller (with spatie/schema-org:^5.0)

My problem is for CollectionPage Schema type.  
They can have a “relatedLink” array for prev and next pages in pagination.

With PaginatedResultSet we have everything to generate previous and next url but this already exists in PaginatorHelper.

Do you know a way to get prev/next url in the controller without rewrite PaginatorHelper::generateUrl() ?

Thanks.

---

<div class="post-metadata">

**Author:** ![ADmad](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/admad/32/20_2.png) [@ADmad](https://discourse.cakephp.org/u/ADmad)\
**Post date:** [September 30, 2026, 6:37am UTC](https://discourse.cakephp.org/t/prev-next-pagination-url-in-controller-from-a-paginatedresultset/12965/2 "2026-09-30T06:37:59Z")

</div>

View helpers are already accessible as a Twig functions [GitHub - cakephp/twig-view: Twig View for CakePHP · GitHub](https://github.com/cakephp/twig-view/#accessing-view)

---

<div class="post-metadata">

**Author:** ![Erwane](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/erwane/32/3253_2.png) [@Erwane](https://discourse.cakephp.org/u/Erwane)\
**Post date:** [October 1, 2026, 7:55am UTC](https://discourse.cakephp.org/t/prev-next-pagination-url-in-controller-from-a-paginatedresultset/12965/3 "2026-10-01T07:55:56Z")

</div>

Really ? good news …

Anyway, you suggest to add related urls from the twig view ?  
Paginator::meta() do this well for tags but adding some “logic” to complete the Structured data object from controller then view sounds not relevant.  
Twig approach is also to reduce the logic part from view no ?
