ideas
ideas copied to clipboard
Expand the native Link fieldtype functionality to include a label (with fallback) and new window toggle
The native Link fieldtype is great, but I think a couple additions could really make it considerably better while preserving backwards compatibility!
- Add an accompanying "Label" field: When filled out, this could override the "inherited" title from a selected asset or entry. For example,
{{ link_field:label }}is your custom label (if one exists). If one doesn't exist then it falls back to the title of the selected entry or asset. - Add a new window toggle: While checking if a link
is_externalis nice, it's not always the reason a client wants something to open in a new window. Putting this into a dedicated control would simplify this.
With this setup, I think the following Antlers API would work great—
<!-- The URL for backwards compatibility -->
{{ link_field }}
<!-- The custom label or the title of the asset/entry -->
{{ link_field:label }}
<!-- A boolean based on the New Window selection -->
{{ link_field:new_window }}
<!-- A shorthand combination for common CTAs <a href="https://example.com" class="px-3 py-1 font-bold">Label</a> -->
{{ link_field:el class="px-3 py-1 font-bold" }}