Skip to content

Commit

Permalink
Build the Page widget's uri from public url of the page. Fixes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainjule committed Dec 5, 2019
1 parent 4844399 commit 6c8973a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 6c8973a

Please sign in to comment.