Today, when I want the web editor to add a link, I have to provide them with two fields - a ContentSelector (if they want to link to site content) and a TextLine (if they want to link to an external URL).
I would like a Link input type, which would let me do both in a single field. Then, in the portal.pageUrl() method, you could simply check if the string provided is a URL or an ID. In the former, simply return the string instead of looking up the absolute URL.
It’s cumbersome for both developers and our web editors to have two fields when you simply want one value.
Oh yeah, great minds think a like. I filed this as a feature request in November, and it’s been approved. Not sure when it gets into core though.
Will help a lot, I do the same many times. Adding it as a mixin was not a bad idea for improving, until now I’ve just done it old fashion copy paste way.
I second that. I remember in 4.7 there was such a nice link feature in the htmlArea but there was no nice link input and people sometimes added htmlAreas to their content-types just for its link feature.
Yes, optionset will solve this and make it possible to create custom solutions.
For instance, create a radio button that let’s you choose “Content” or “External URL”. Selecting “Content” option will display any extra input fields you desire, while choosing “External URL” will display another set of fields. It can be just a ContentSelector for the first one, and a TextLine with a CheckBox “open in new window” for the second one.
Will it also be possible with the new optionset feature to do some more advanced scripting such as provide default values based on selected values or is it limited to more “static” values set in the Schema?
Hmmm, lets try to explain with an example:
Say you set the optionset to trigger when selecting a value in a ContentSelector, and then when you select a Content with ContentType A in the ContentSelector, you get a input field with default value to the name of the Content you selected.
But if you select a Content with ContentType B then that text field is blank but you will also display a checkbox?