Use $page->render() for a specific language and supply data

I’m using the route from the docs (second one) to render a page:

  'pattern' => '(:any)/(:num)',
  'language' => '*',
  'page' => 'blog',
  'action' => function ($language, $page, $filter, $pageNum = null) {
    return $page->render([
      'pageNum' => $pageNum,
      'category' => $category,
      'tag' => $tag

However, I can’t set the page language in render(). In a similar issue, it was suggested to use $site->visit(), but that can’t work for me because I need to pass data to the page, and visit() can’t do that.

What should I do?

Use site()->visit() first, then render.

1 Like