Skip to content

[6.x] Resolve entry links in nav page urls - #15719

Open
Arda-dd wants to merge 1 commit into
statamic:6.xfrom
Arda-dd:fix/nav-link-field-url
Open

Arda-dd wants to merge 1 commit into
statamic:6.xfrom
Arda-dd:fix/nav-link-field-url

Conversation

@Arda-dd

@Arda-dd Arda-dd commented Oct 24, 2026

Copy link
Copy Markdown

Fixes #15628.

A navigation blueprint can define the url field as a link field. Picking an entry there stores a reference such as entry::4af6f16d-… as the page's url. The CP keeps the field config (ensureField('url', []) doesn't override it). Page::url() returned that stored value as it was, so {{ url }} in a nav tag rendered href="entry::4af6f16d-…". Link fields with any other handle were already resolved by the Link fieldtype's augmentation.

Changes

  • Page::url(), urlWithoutRedirect() and absoluteUrl() resolve link references (anything Link::types() knows, so entry:: and asset:: and addon link types) through ResolveRedirect, the same way the Link fieldtype does. uri() and absoluteUrlWithoutRedirect() go through those methods. Entries are localized to the current site unless the nav can select across sites; an entry on another site gets its absolute url, as for entry pages ([6.x] Fix nav entry links across sites losing their domain #15239).
  • A link to an entry that no longer exists gives null instead of the raw reference.
  • Plain urls are returned unchanged. Only values containing :: go through the resolver.
  • The CP page editor needs the stored reference, not the url it resolves to, otherwise saving the page would replace the link with a plain url. NavigationPagesController now reads it from a new Page::customUrl(), which pairs with the existing hasCustomUrl().

Tests

  • PageTest: a page whose url is entry::123 resolves to the entry's url in all the url methods, and a link to a missing entry has no url.
  • EditNavigationPageTest: the page editor gets the stored entry::123.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Entry IDs not resolving into URLs in navigation template

1 participant