0

In my app I'm calling an API to get the list of tasks as view(It has a complex html structure) and It is working correctly.

But now I have to create a pagination for it. How can I pass the pagination to the renderRoot method?

public function getTaskItems() {

  $view_arguments = ['2019-11-01'];

  $build['view'] = [
    '#type'      => 'view',
    '#name'      => 'task_items',
    '#arguments' => $view_arguments,
  ];

  $rendered = \Drupal::service('renderer')->renderRoot($build);

  $response = new Response();
  $response->setContent($rendered);
  return $response;
}
  • You don't. Drupal pagers are working with global variables and you control the page with a query string on the request. – 4k4 Sep 4 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.