From 1e37450271a8e0b71d95563e95544ee03da10bd2 Mon Sep 17 00:00:00 2001 From: Stuart Cusack Date: Sat, 3 Sep 2022 17:10:37 +0100 Subject: [PATCH] Fix view data initiation --- src/ServiceProvider.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index faecdc8..9c18e21 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -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() { @@ -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)); }