Skip to content

Commit

Permalink
Fix view data initiation
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcusackie authored Sep 3, 2022
1 parent 54bc64c commit 1e37450
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ protected function registerServices()
}

/**
* Process the view data that has been set up
* by Statamic. This is very convoluted but
* it's efficient!
* Attempt to find an entry of term from the
* current url and extract the data from it's
* template view.
* Not ideal but it works!
*/
protected function registerViewComposers()
{
Expand All @@ -41,9 +42,7 @@ protected function registerViewComposers()
// Remove multisite url prefixes if necessary (we can't find entries by uri when they are prefixed)
foreach(\Statamic\Facades\Site::all() as $site) {

$sitePrefix = str_replace(request()->root(), '', $site->url);

if(strlen($sitePrefix) && str_starts_with($path, $sitePrefix)) {
if(strlen($site->url) > 1 && str_starts_with($site->url, '/') && str_starts_with($path, $site->url)) {
$path = substr($path, strlen($sitePrefix));
}

Expand Down

0 comments on commit 1e37450

Please sign in to comment.