Here you see 3 types of common use cases to specify links. A single link field is often not enough. Users and developer have a lot of ideas for links, which are often not easy to manage via the standard fields. It ends up in a complete mess of Switchable Fields combined with composite fields. I also saw a combination of a multi value, switchable, combosite field (weird).
The JCR structure is also complex and ends up in a lot of useless code. If you think of new ways to maintain content like stories apps this could be even more complex because beside Internal, External and Download links you probably have links to News Article or Events...
For the Author this is as well a desaster. It's not easy to understand this mess of fields.
Make it a joy to use links in a couple of ways, flexible and extensible.
- Link fields if a user needs to decide what to link. This could be a teaser, link component or even a redirect page template.
- Common features for links are:
- Author defines a link text, or it's picked up from the linked page or asset
- Author references to a internal page, download or uses a external page
- User want's to define if the link is opened in a new window or not
- Users want's to define an anchor tag inside a page. "Link Suffix"
This is a working example of an advanced link field. It's an standard richtextfield which has a custom CSS and JS. The field is a one liner and you can just define links. Enter or Shift Enter are blocked. It's only generating an a-Tag without <br> or <p> wrappers.
The nice thing behind it is that you can easily define anything you like. You can add formatting if needed and you can easily add it into a multi value context.
This type of field is nice if you want exactly the criterias of the screenshots above.
But it has downsides, which are not solved yet, but i guess this should not be a show stopper:
- At the moment everything is added into one jcr property which is basicly a RichTextField-HTML. But sometimes you would like to have all the specified items in splitted variables. (Link Text, Link Target, Link Href)
- The asset and the internal Link Picker don't have the ability to add a _blank target. (You can pick it and after that open the link dialog)
- If you only want to define a link without all the stuff around it you need to manipulate the JS for CK Editor, and add some kind of transformer, as we all know from standard link fields.
- You don't have an image preview if you choose an image.
- It's all saved into one field which makes it easier
- This solution relies on CK Editor which is hard to configure if you are not familiar with it.
- There are two kinds of link fields possible
- You can define a link text on your own. But you want to split the link and the linktext into seperate variables.
- You can define no specific link text.