Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There are several modules allowing users to open links in a new window:
- http://www.drupal.org/project/menu_link_attributes
- http://www.drupal.org/project/editor_advanced_link
All modules use a different way of allowing the users to do this:
- This module uses a textfield
- menu_link_attributes uses a select field
- editor_advanced_link uses a checkbox
Proposed resolution
It would be nice to provide editors with the same options everywhere. I think the checkbox is the easiest/ most user friendly, but if you want to have several options I guess the select field is the most flexible solution. So let's convert the textfield to a select box.
Remaining tasks
Change the text field to a select field.
Discuss what to do with existing widgets/data.
User interface changes
The textfield will be converted to a select field.
API changes
-
Data model changes
-
Comment | File | Size | Author |
---|---|---|---|
#12 | interdiff-10-12.txt | 6.12 KB | seanB |
#12 | 2893078-12.patch | 7.42 KB | seanB |
#10 | interdiff-8-10.txt | 981 bytes | seanB |
#10 | 2893078-10.patch | 5.5 KB | seanB |
#8 | 2893078-8.patch | 5.52 KB | seanB |
Comments
Comment #2
seanBComment #3
seanBCreated #2893079: Target option as select field as well.
Comment #4
larowlanI'd support this if it could be done in a way that didn't introduce a switch or else statement.
So it would probably require moving the attributes to plugins.
Comment #5
seanB+1 on moving attributes to plugins. I'll try to create a patch for that asap.
Comment #6
larowlanIdeally we could do this without changing the data structure.
So that would require the plugin IDs matching the attribute names.
Thanks
Comment #7
larowlanFWIW I would support yaml based discovery for this
A base class would handle most cases.
Comment #8
seanBOk, this should do it. Decided to remove the field descriptions, they didn't seem to add any value. I could add them back if you want, but it seems better this way.
The data structure is still intact, so besides the field description and the select for the target nobody should notice a thing. Changing the target to a select means that manually entered values other then _self or _blank could cause an issue. Links that used to open in a new window will return to the default value _self after saving the content. Not sure what to do with those?
Comment #10
seanBOptions should not be a default property. Also fixed leftover docs from drupal console.
Comment #11
larowlanThis is looking great, really simple.
Adding tag to update documentation.
can we short syntax here, thanks
Please remove this - console cruft?
If its missing, lets default to 'textfield' and then remove the 'textfield' from the yml file, so we only have to nominate type if its out of the ordinary, less verbose
Please implement ContainerFactoryPluginInterface for the widget and inject
Nit: let's drop the local variable, not used elsewhere
Can you use array_map here and avoid the foreach, the keys are the same.
Thanks again, great work
Comment #12
seanBThanks for the review! Addressed all feedback, updated patch is attached.
Comment #13
larowlanNit, private => protected, we don't really use private much in Drupal - can be fixed on commit
oh for php7 and null coalesce :)
Thanks again
Comment #14
larowlanComment #15
seanBThanks for pointing out those last things! :)
Comment #17
larowlanFixed, thanks
Rolling a 1.1 release and updating docs