Pagination: removing "page;" from the url pattern

By using the built-in Kirby pagination, the current URL is extended by “page; 2” or “page; 3”. Example: The URL https: //kirby.fantastic-asia.local/Individualreisen becomes https: //kirby.fantastic-asia.local/Individualreisen/page; 2. I want the ‘/page;2’ to go away. The last parameter looks to me like a GET that is simply appended to the URL. Therefore I have created the following routes in the config. php:

'routes' => 
[
    [
         'pattern' => 'Individual trips /? page; = (: num)',
         'action' => function ($ page) {
           go ('Individual Travel /'.$ page);
         }
       ],
       [
         'pattern' => 'Individual trips / (: num)',
         'action' => function ($ page) {
           $ _GET ['page'] = $ page;
           return site () -> visit (page ('Individual Travel'));
         }
    ]
]

Unfortunately I don’t seem to meet the search pattern ‘Individualreisen /? Page; = (: num)’. Can anybody help me further?

Best regards
Lutz

  1. Variables start with a $ character in PHP.
  2. go() needs a path to a page, not a page title
  3. and most important, query strings and parameters cannot be queried in a pattern, you would have to check that inside the route.

What you would need is something like this:

'routes' => [

    [
      'pattern' => 'notes',
      'action' => function () {
          dump(param('page'));
          return go( 'notes/' . param('page') );
        
      }
    ],
    [
      'pattern' => 'notes/(:num)',
      'action' => function ($num) {
        $notes = page('notes')->children()->paginate(1);
        $pagination = $notes->pagination();
        if ( $num > $pagination->pages() ) {
          go('error');
        }
        $data = [
          'paginationPage' => $num,
        ];
        return page('notes')->render($data);
      }
    ]
  ]

But you would also have to handle this in your controller to make sure the correct pagination page is returned (therefore we return the page to controller when rendering the page).

Please indent your code properly using three backticks before and after your code block.