Problem/Motivation
For my use case. Only the _blank target is needed/wanted inside the target selection dropdown. I'd prefer to use this module, instead of creating a custom one.
Proposed resolution
Make the list of target items configurable.
Remaining tasks
Create configuration form where possible target selection items can be selected with checkboxes.Get configured available targets in field formatter, instead of using hardcoded ones.- Review & Test.
- Commit.
User interface changes
Configuration form added.
API changes
None.
Data model changes
Available targets configuration added.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | interdiff-link_target_10-13.txt | 3.1 KB | mandclu |
| #13 | link_target-configure_targets-3044960-13.patch | 5.51 KB | mandclu |
Comments
Comment #2
orlando.thoenyComment #3
orlando.thoenyI could implement this if the feature is desired.
Comment #4
jacobfrancke@gmail.com commentedHi Orlando,
This sounds good, I don have time myself to implement this, so feel free to do this :-)
Thanks!
Comment #5
orlando.thoenyI created a config for the link targets. Also a settings page. Updated Readme and made it Markdown. The configuration is set via update hook for existing installs. I'd put that into the release notes. If someone runs
drush cimafterwards, it will be removed, so it has to be exported to the config files first withdrush cex.Comment #6
orlando.thoenyComment #7
scuba_flyWow really nice! work like a charm!
Tested by updating the module with this patch. I see that you have an update hook in place that creates the config.
Totally makes sense.
It's a really big patch, but I could not find any issues with it.
I tried selecting only _blank and _self. and it just works!
Comment #8
mandclu commentedA much simpler approach would be to make this part of the widget settings, and this would also give a site builder the option of having different targets available per content type or bundle.
The attached patch implements this approach, please test.
Comment #9
maursilveira commentedHello @mandclu,
I tested your patch against the dev version, and I get the following error in the form display:
The problem is that you are using
$thisinside a static function.You can either make that function not static or simply use
t().Thank you.
Comment #10
mandclu commented@maursilveira thanks for the feedback. Here's an updated patch that should address the error you found.
Comment #11
mandclu commentedComment #12
maursilveira commentedHello @mandclu.
Patch #10 fixes the reported issue, and it works great. I took the liberty to add a couple of changes to it in the patch attached into this comment.
1. Display the message "No target options were selected." in the function
settingsSummary()if no available target options are selected. The previous code was displaying "Available targets:".2. Remove the select element "Select a target" from the add/edit form if no available target options are selected. The previous code generated the target selector, but the only option was "- None -".
Could you please review it? Please let me know what you think about this, or if you have any questions.
Thank you.
Mauricio
Comment #13
mandclu commentedThanks for the additional feedback. I agree that the previous patch didn't properly handle an empty set of targets, but I think the solution should be to default to showing all instead. If they don't want any targets allowed, why use this widget at all?
Here's an updated patch that should fix the behaviour, to show all target options if none were selected.
I wasn't able to generate an interdiff from your patch (the error was "Whitespace damage detected in input") so providing an interdiff from the patch in #10 instead.
Comment #14
maursilveira commentedHello @mandclu,
I totally agree with you. I made that change to hide the filter when no available options were selected because I thought that was by design. But I agree that if no options are manually selected that should mean that all options will be available.
I tested the patch in #13 and it works great. Thank you for the patch.
Mauricio
Comment #16
mandclu commentedThanks again for all your feedback and help on this issue. Merged in, and will roll a new release shortly.
Comment #17
mandclu commented