Skip to content

Commit 6c8973a

Browse files
committed
Build the Page widget's uri from public url of the page. Fixes #19
1 parent 4844399 commit 6c8973a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

index.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,20 @@
7373
$uris = [];
7474
foreach(kirby()->languages() as $language) {
7575
$code = $language->code();
76-
$uris[$code] = $this->model()->uri($code);
76+
// re-create the uri from the public url
77+
$currentUrl = $this->model()->url($code); // get the page url
78+
$currentUri = str_replace(site()->url(), '', $currentUrl); // substract the site url to get the uri
79+
$currentUri = '/' . ltrim($currentUri, '/'); // make sure it starts by a single forward slash
80+
$uris[$code] = $currentUri;
7781
}
7882
return $uris;
7983
}
8084
else {
81-
return $this->model()->uri();
85+
// re-create the uri from the public url
86+
$currentUrl = $this->model()->url(); // get the page url
87+
$currentUri = str_replace(site()->url(), '', $currentUrl); // substract the site url to get the uri
88+
$currentUri = '/' . ltrim($currentUri, '/'); // make sure it starts by a single forward slash
89+
return $currentUri;
8290
}
8391
},
8492
'lang' => function() {

0 commit comments

Comments
 (0)