Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize the parent tag #4294

Merged
merged 2 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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