Skip to content

[5.x]: Getting an entry URL of a Link field vs an Entry field in a multi site setup #16458

@svossen

Description

@svossen

What happened?

Description

I have a multi site setup for different locales. When building a navigation I both tried the Entries field and the Link field to link to an entry. I don’t translate the field, since the link to the entry is the same for every website. So it doesn’t really make sense to make in translatable.

When using Entries, when I try to get the URL of the linked entry, I get the URL for the current website. When I do this for the Link field, I always get the URL for the parent website, even if it’s not the current website. After reading #15821 and #16274, this seems to be intentional behavior.

Steps to reproduce

  1. Create a multi website setup, where each website has it’s own URL.
  2. Add a new section named page. And add a new record.
  3. Create a new entry type named navigation link.
  4. Add a field of the type Entries.
  5. Add a field of the type Link.
  6. Create a new record for navigation link, link both field to the same page entry.
  7. In Twig get the URL of the page entry with something like the code below.
{{ dump(navigationLink.entryFieldTest.one().url) }}
{{ dump(navigationLink.linkFieldTest.value) }}

Expected behavior

It would be nice to get the linked entry URL of the current website for a non-translated Link field.

Actual behavior

For a non-translated Link field, I get the linked entry URL of the parent website.

Craft CMS version

5.5.10

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions