Bug description
On a multi-site install with sites on different domains, a nav item linking to an entry on another site renders {{ url }} with the scheme and host stripped, so the browser resolves it against the current site and 404s.
A nav on a Museum site at https://museum.test, linking to the Foundation site's projects entry, renders <a href="/projects"> instead of <a href="https://foundation.test/projects">. {{ permalink }} on the same item is correct, so only {{ url }} is affected.
{{ url }} resolves to Entry::url() and therefore Routable::urlWithoutRedirect(), where absoluteUrlWithoutRedirect() builds the correct host from the target entry's site and URL::makeRelative() then drops it unconditionally:
publicfunctionurlWithoutRedirect()
{
if (! $url = $this->absoluteUrlWithoutRedirect()) {
returnnull;
}
returnURL::makeRelative($url);
}This looks like the nav equivalent of #12694, which fixed the same thing for Bard entry links by returning absoluteUrl() when select_across_sites is enabled. Navs have that setting too, but weren't covered.
It also affects is_current and is_parent, which Structure::toArray() derives from that same host-less URL, so a cross-site item can be flagged active when the two sites happen to share a path.
How to reproduce
- Two sites on different domains:
museum:
url: 'https://museum.test/'foundation:
url: 'https://foundation.test/'
- A routable
pages collection on both sites, with a projects entry in foundation. - A
main nav with select_across_sites: true. - In the museum tree, add an item linking via entry (not via URL) to that
foundation entry. - Render it on the museum site:
{{ nav:main }}{{ title }} — url: {{ url }} — permalink: {{ permalink }}{{ /nav:main }}Expected url: https://foundation.test/projects
Actual url: /projects (permalink is correct)
Environment
EnvironmentLaravel Version: 13.26.1PHP Version: 8.5.8Composer Version: 2.10.2Environment: localDebug Mode: ENABLEDMaintenance Mode: OFFTimezone: UTCLocale: enCacheConfig: NOT CACHEDEvents: NOT CACHEDRoutes: NOT CACHEDViews: CACHEDDriversBroadcasting: logCache: fileDatabase: sqliteLogs: stack / singleMail: logQueue: syncSession: fileStoragepublic/storage: LINKEDLivewireLivewire: v4.4.1StatamicAddons: 10License Key: Not setSites: 3Stache Watcher: Enabled (auto)Static Caching: DisabledVersion: 6.28.0 PROStatamic Addonsaryehraber/statamic-captcha: 1.17.0jacksleight/statamic-bard-mutator: 3.0.5jacksleight/statamic-distill: 1.2.0marcorieser/statamic-livewire: 5.3.1statamic-rad-pack/typesense: 3.2.2statamic/podcast-categories: 2.0.0statamic/seo-pro: 7.13.2transformstudios/events: dev-fix/calendar-day-timezone-mismatchtransformstudios/prime: dev-releasetransformstudios/review: 6.0.0
Installation
Fresh statamic/statamic site via CLI
Additional details
Reproduced on 6.28.0; the same code path is on 5.x. Worth noting Structure::toArray() is shared by {{ nav }} and {{ structure }}, but select_across_sites only exists on navs.
Bug description
On a multi-site install with sites on different domains, a nav item linking to an entry on another site renders
{{ url }}with the scheme and host stripped, so the browser resolves it against the current site and 404s.A nav on a Museum site at
https://museum.test, linking to the Foundation site'sprojectsentry, renders<a href="/projects">instead of<a href="https://foundation.test/projects">.{{ permalink }}on the same item is correct, so only{{ url }}is affected.{{ url }}resolves toEntry::url()and thereforeRoutable::urlWithoutRedirect(), whereabsoluteUrlWithoutRedirect()builds the correct host from the target entry's site andURL::makeRelative()then drops it unconditionally:This looks like the nav equivalent of #12694, which fixed the same thing for Bard entry links by returning
absoluteUrl()whenselect_across_sitesis enabled. Navs have that setting too, but weren't covered.It also affects
is_currentandis_parent, whichStructure::toArray()derives from that same host-less URL, so a cross-site item can be flagged active when the two sites happen to share a path.How to reproduce
pagescollection on both sites, with aprojectsentry infoundation.mainnav withselect_across_sites: true.foundationentry.{{ nav:main }}{{ title }} — url: {{ url }} — permalink: {{ permalink }}{{ /nav:main }}Expected
url:https://foundation.test/projectsActual
url:/projects(permalinkis correct)Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
Reproduced on 6.28.0; the same code path is on
5.x. Worth notingStructure::toArray()is shared by{{ nav }}and{{ structure }}, butselect_across_sitesonly exists on navs.