Linking to things tends to be important in a CMS, and has high reuse value.
This can be observed in the large download numbers for GitHub - sheadawson/silverstripe-linkable: Easily add external or internal links to a dataobject with a dialog form. I’m keen to start a conversation with module authors on how we can take this forward.
Shea’s module is now deprecated. A common replacement is GitHub - gorriecoe/silverstripe-linkfield: Adds a Linkfield for gorriecoe/silverstripe-link
(plus the underlying data model of GitHub - gorriecoe/silverstripe-link: Adds a Link Object that can be link to a URL, Email, Phone number, an internal Page or File.).
The has_one UI is pretty cruddy (it’s using GridField’s defaults)
We’ve also created a similar (more limited) implementation of this as part of GitHub - silverstripe/silverstripe-elemental-bannerblock: A banner block for the dnadesign/silverstripe-elemental module.
It only supports internal links (see Should support external links · Issue #23 · silverstripe/silverstripe-elemental-bannerblock · GitHub), but has a nicer way to manage them (in a modal).
And it is tied to the concept of a “banner”, but should really be useable outside of that (see Should BlockLinkField be pulled out into its own module? · Issue #10 · silverstripe/silverstripe-elemental-bannerblock · GitHub).
In my opinion, all of these modules have a shortcoming in terms of UX: They force users
to treat links as an object that’s managed on it’s own screen, rather than something that’s easily inlined.
This becomes particularly apparent in blocks implementations where the inline editing flow becomes more important due to granular content creation (e.g. a “call to action” button)
- Supports linking to internal pages and external URLs
- Supports linking to emails
- Supports grouping links in has_many or many_many relationships (incl. sorting)
- Can choose to open links in new window
- Validates formats (e.g. valid email addresses)
- Optinally supports linking to phone numbers (with good template defaults to make them behave like phone numbers)
- Can be extended (e.g. to support custom formatted links to VOIP apps based on staff name lookup)
- Same data model can be managed in different ways (= separate out form field into own module)
- Supports drafting changes in links before publishing them
- Can be folded into other form contexts without requiring it’s own detail view to reduce editing friction
- Only shows options releva
- Supports more than one link editing UI in the same form
- Regarding folding this into other form contexts (e.g. GridField), I see two options:
- Option A: CompositeField which can be either applied to a “Link” DataObject, or any other DataObject directly. CompositeField would create database columns like “PageID”, “ExternalURL”, “OpenInNewWindow” etc
- Option B: Create a form field which can manage a has_one relationship inline
- Techncailly, we also have SilverStripe’s built in “link” modal dialog for HTML content, which only supports writing to HTML embedded shortcodes, not data objects. I don’t think those use cases need to overlap, because it’ll introduce quite a lot of complexity.