Skip to content

Commit

Permalink
Localize the parent tag
Browse files Browse the repository at this point in the history
Fetch the parent data from the current site/locale. Fixes #2991
  • Loading branch information
daiwai committed Sep 21, 2021
1 parent ef63bf2 commit 3221798
Show file tree
Hide file tree
Showing 2 changed files with 4 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
7 changes: 3 additions & 4 deletions src/Tags/ParentTags.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Statamic\Tags;

use Statamic\Facades\Entry;
use Statamic\Facades\Site;
use Statamic\Facades\URL;
use Statamic\Support\Arr;
use Stringy\StaticStringy as Stringy;
Expand Down Expand Up @@ -71,9 +72,7 @@ private function getParentUrl()
*/
private function getParent()
{
$crumbs = [];

$segments = explode('/', URL::getCurrent());
$segments = explode('/', URL::tidy(URL::removeSiteUrl(URL::getCurrent())));
$segment_count = count($segments);
$segments[0] = '/';

Expand All @@ -92,7 +91,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 3221798

Please sign in to comment.