Skip to content

Commit

Permalink
Localize the parent tag (#4294)
Browse files Browse the repository at this point in the history
  • Loading branch information
daiwai authored Sep 22, 2021
1 parent ed29b8c commit 68b6ac9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Facades/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @method static \Statamic\Entries\EntryCollection whereCollection(string $handle)
* @method static \Statamic\Entries\EntryCollection whereInCollection(array $handles)
* @method static null|\Statamic\Contracts\Entries\Entry find($id)
* @method static null|\Statamic\Contracts\Entries\Entry findByUri(string $uri)
* @method static null|\Statamic\Contracts\Entries\Entry findByUri(string $uri, string $site)
* @method static \Statamic\Contracts\Entries\Entry make()
* @method static \Statamic\Contracts\Entries\QueryBuilder query()
* @method static void save($entry)
Expand Down
8 changes: 4 additions & 4 deletions src/Tags/ParentTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace Statamic\Tags;

use Statamic\Facades\Entry;
use Statamic\Facades\Site;
use Statamic\Facades\URL;
use Statamic\Support\Arr;
use Statamic\Support\Str;
use Stringy\StaticStringy as Stringy;

class ParentTags extends Tags
Expand Down Expand Up @@ -71,9 +73,7 @@ private function getParentUrl()
*/
private function getParent()
{
$crumbs = [];

$segments = explode('/', URL::getCurrent());
$segments = explode('/', Str::after(URL::getCurrent(), Site::current()->url()));
$segment_count = count($segments);
$segments[0] = '/';

Expand All @@ -92,7 +92,7 @@ private function getParent()

// Find the parent by stripping away URL segments
foreach ($segment_urls as $segment_url) {
if ($content = Entry::findByUri($segment_url)) {
if ($content = Entry::findByUri($segment_url, Site::current())) {
return $content->toAugmentedArray();
}
}
Expand Down

0 comments on commit 68b6ac9

Please sign in to comment.