• Angebot bei Thaihe in Düsseldorf

    45 Minuten 40 Euro Zum Thema

Kirby CMS Static Pages

Deutsch

Massagekenner
Kenner

Kirby CMS Static Pages

Immer dann, wenn betreuende Personen eines System auch Webseitenbau verkaufen, kann man auf Leute oder auch Systeme stoßen, bei denen der Support eine recht komische Sache ist. Da wird verwiesen, gedruckst oder auch geschwiegen. Und dann braucht man ein vielfaches an Stunden, weil die Infos fehlen und man Gott und die Welt anschreiben muss bis sich dann einer findet, der einem aus der Patsche hilft.

Ob das bei Kirby auch so ist, würde ich nie behaupten wollen. Was ich sagen kann, ist dass ich dutzende von Stunden nach Lösungen gesucht habe und sowas ziemlich nervig und anstrengend ist. Die Docs zu Kirby sind bestimmt ganz toll, man verweist auch gerne darauf und meint, dass da doch alles stehen würde.
 
Schreiben vom Entwickler der Kriby static pages zur Lösung des gefundenen Fehlers:

Code:
Once the linked PR is merged, update to version 1.9.0 of the plugin. Something like this should then work:

In the routes:

 [
 "pattern" => "generate-static-site/(:any)/page:(:num)", 
 "action" => function ($pageId, $pageNum) {
 $params = kirby()
  ->request()
  ->url()
  ->params();
 $params->page = $pageNum;
 $html = page($pageId)->render();

 $params->page = null; // reset the param after rendering the page
 return $html;
 }, 
 ]

and in your example you'd switch the custom routes so they are like this:

$myRoutes[] = [
 "path" => "de/notes/$i", 
 "page" => "notes", 
 "route" => "generate-static-site/notes/page:$i", 
 "languageCode" => "de", 
];
$myRoutes[] = [
 "path" => "en/notes/$i", 
 "page" => "notes", 
 "route" => "generate-static-site/notes/page:$i", 
 "languageCode" => "en", 
];

The new thing here is that you can now add a page to the custom route so that when rendering the route there is an additional page context which is used when rendering the pagination links.
You will still have to manually reformat the pagination links from page:x to /x in your template, but the base URL should now work and there should be no mixup of languages.

You can also completely skip adding a "proxy" route and instead just render the custom routes without pointing to a route. You can then add the page as a template variable by using the data attribute in the custom routes.

Example:

$myRoutes[] = [
 "path" => "de/notes/$i", 
 "page" => "notes", 
 "languageCode" => "de", 
 "data" => ["pageNum" => $i]
];
$myRoutes[] = [
 "path" => "en/notes/$i", 
 "page" => "notes", 
 "languageCode" => "en", 
 "data" => ["pageNum" => $i]
];

Then, in your template you can get the current page number like this:

$pageNumber = $pageNum? param('page')? 1;

Then, when calling ->children()->paginate( just pass it as the second argument to set the current page number. Documentation: https://getkirby.com/docs/reference/objects/cms/pages/paginate
 
Zurück
Oben