From 6c8973aa818e4efc15f79ded2dac4894f7901103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sylvain=20Jul=C3=A9?= Date: Thu, 5 Dec 2019 11:15:03 +0100 Subject: [PATCH] Build the Page widget's uri from public url of the page. Fixes #19 --- index.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 5e415ec..0c940c3 100644 --- a/index.php +++ b/index.php @@ -73,12 +73,20 @@ $uris = []; foreach(kirby()->languages() as $language) { $code = $language->code(); - $uris[$code] = $this->model()->uri($code); + // re-create the uri from the public url + $currentUrl = $this->model()->url($code); // get the page url + $currentUri = str_replace(site()->url(), '', $currentUrl); // substract the site url to get the uri + $currentUri = '/' . ltrim($currentUri, '/'); // make sure it starts by a single forward slash + $uris[$code] = $currentUri; } return $uris; } else { - return $this->model()->uri(); + // re-create the uri from the public url + $currentUrl = $this->model()->url(); // get the page url + $currentUri = str_replace(site()->url(), '', $currentUrl); // substract the site url to get the uri + $currentUri = '/' . ltrim($currentUri, '/'); // make sure it starts by a single forward slash + return $currentUri; } }, 'lang' => function() {