Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Link field allows entries without urls #153

Closed
dgsiegel opened this issue Apr 14, 2021 · 7 comments
Closed

Link field allows entries without urls #153

dgsiegel opened this issue Apr 14, 2021 · 7 comments

Comments

@dgsiegel
Copy link

I do have a few sections which do not have a URL (empty site settings in the section configuration). With Link field you can still choose these sections if you enabled the selection of entries in a link. The result looks like the following:

 typedlinkfield\models\Link {#2177 ▼
  +ariaLabel: null
  +customQuery: null
  +customText: "foo"
  +target: null
  +title: null
  +type: "entry"
  +value: "2340"
  -prefetchedElement: craft\elements\Entry {#2163 ▶}
  -linkField: typedlinkfield\fields\LinkField {#1064 ▶}
  -owner: craft\elements\MatrixBlock {#1778 ▶}
  -_errors: null
  -_validators: null
  -_scenario: "default"
  -_events: []
  -_eventWildcards: []
  -_behaviors: []
}

Ideally, a user should not be able to choose entries without a URL.

@sebastian-lenz
Copy link
Owner

Hi @dgsiegel, you can control which sections the user can pick linked elements from within the field settings. You can disable those sections that do not expose an url there. Check the settings page of the individual link field you've created, you've probably selected the option to allow all sections.

As users might do all kind of stuff with the information about the linked element, I don't think we should restrict the sections to only those exposing urls.

@dgsiegel
Copy link
Author

I know that I could choose the sections individually, but that is not feasible in this case as we use a high number of link fields. But that would be something for #47.

The actual issue is the link being empty, something a user would probably not expect. After all, what's the reason for an empty link? What kind of use cases are you thinking about?

@michaelroper
Copy link

michaelroper commented Apr 16, 2021

@dgsiegel I actually have a use-case for that - i have a section of entries that are reusable content for "modal dialogs". They aren't displayed on their own, hence they have no URLs. I am using the LinkField to be able to select those "modal" entries and assign them to a button (instead of a href) to open a modal with that entry content.

I do get your point around the pain of having to modify multiple field instances to exclude them - I ended up configuring my desired settings on one field, and then doing some copy/paste work directly in the project config yaml files of the other field instances, and then doing ./craft project-config/apply to apply those changes..

@dgsiegel
Copy link
Author

dgsiegel commented Apr 16, 2021

I do use a similar setup, but the correct field for that would be an entry field, not a Link field?

@michaelroper
Copy link

True - but the Link field gives me the flexibility for my button/action to link to either an entry with a url (eg a page), one with out a url (like a modal), or just a custom url..

@sebastian-lenz
Copy link
Owner

Okay, I think we definitely should not disable this but I can understand that it might be handy to have this as an option.

@mtnorthrop
Copy link

I also set up modals as entries and link to them using the link field, just like michaelroper described, so I'd also hate to see this functionality disappear! :-)

Repository owner locked and limited conversation to collaborators Feb 26, 2022
@sebastian-lenz sebastian-lenz converted this issue into discussion #191 Feb 26, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

4 participants