Allow filtering the link autocomplete by content type. This patch adds a checklist of content types to the link field settings and filters the autocomplete in the widget to only return nodes of one of the content types selected in the settings.
| Comment | File | Size | Author |
|---|---|---|---|
| #62 | 2887376-62.patch | 12.39 KB | glenndw |
| #54 | reroll_diff_50-54.txt | 7.73 KB | jhandsta |
| #54 | 2887376-54.patch | 11.22 KB | jhandsta |
| #50 | interdiff_47-50.txt | 1.46 KB | atul4drupal |
| #50 | 2887376-50.patch | 11.35 KB | atul4drupal |
Issue fork drupal-2887376
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2887376-link-autocomplete-content
changes, plain diff MR !7695
Comments
Comment #2
cilefen commentedComment #3
cilefen commentedComment #5
robpowelllet's try this reroll against 8.4.x
Comment #6
robpowellComment #9
rob230 commentedYour patch worked for me, however it has an error: invalid argument supplied for foreach() when you haven't chosen any of the checkboxes yet.
I'll submit a patch that fixes that.
It would be great to get this in core. I have a lot of content types and most of them I don't want to show up as potential links.
Comment #10
rob230 commentedComment #11
rob230 commentedRerolling for 8.5.x.
Comment #13
ryan.ryan commentedThe patch applies cleanly and works as expected. Does this need test coverage to make it into core?
Comment #14
michael_wojcik commentedRe-rolled patch for 8.6.x and added validation of optional content type within
LinkWidget::validateUriElement.Original patch did not include validation step for fields that make use of this new content type restriction option.
Comment #16
michael_wojcik commentedPatch re-rolled to update schema after test failure.
Comment #18
michael_wojcik commentedRe-rolled for core unit test coverage.
Comment #20
michael_wojcik commentedUpdates after further failed tests.
Comment #21
michael_wojcik commentedMislabeled interdiff.
Comment #23
michael_wojcik commentedComment #24
michael_wojcik commentedComment #25
michael_wojcik commentedComment #26
michael_wojcik commentedComment #27
michael_wojcik commentedComment #31
michael_wojcik commented#31 is simply a Drupal-8.5.x backport (for anyone who needs it) of #26, which is compatible with Drupal-8.6.x.
#26 should be the patch to be committed or updated going forward.
Comment #32
rbayliss commentedI think this can be expressed as:
$content_types = array_filter($content_types);
That should filter out all of the non-selected content types.
Content types = node. We always know we're going to have a node here, so we should just check for the existence of $params['node'], then explicitly use node storage.
I think this message could be clearer. What about something like "You have referenced content of a type that is not allowed here. Allowed types: @content_types."
You can use array_filter() here too.
Comment #33
michael_wojcik commentedRe-rolled patch for 8.6.x and 8.5.x based on comments in #32. Thanks @rbayliss!
Regarding the second proposed change in #32: Because of the ongoing work in https://www.drupal.org/node/2423093 to allow for multiple entity types within entity_autocomplete fields, I think we should try to keep our new code as generalized as possible, to allow for additional entity types in the future. I've adjusted the patch accordingly.
Comment #34
michael_wojcik commentedUpdated patch to use more accurate
entity_bundlesname instead ofcontent_typesnames for new field setting, to support future work being done in https://www.drupal.org/node/2423093.Comment #35
michael_wojcik commentedComment #36
michael_wojcik commentedChanged entity bundle field setting widget to use a select input instead of a checkbox.
Added human-readable entity bundle labels for error messages.
Comment #39
navneet0693 commentedRe-rolled for 8.7.x
Comment #43
rahulrasgon commentedRe-rolled for 8.9.x
Comment #45
rahulrasgon commentedRe-rolled for 9.2.x
Comment #46
chetanbharambe commentedHi @rahulrasgon,
Above test cases, #45 is getting failed.
Can you please check it once again and attached some before and after screenshots.
Needs to be re-rolled for 9.3.x
Can be a move to Needs work
Comment #47
suresh prabhu parkala commentedUpdated patch for 9.3.x. Please review.
Comment #50
atul4drupal commentedAdding patch for 9.3.x
Comment #54
jhandsta commentedRe-rolled for 10.2.x
Comment #55
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #59
rahulrasgon commentedComment #60
rahulrasgon commentedComment #61
smustgrave commentedHave not reviewed but issue summary doesn't follow correct template
Comment #62
glenndw commentedRe-rolled for 10.3.9
Comment #63
dcam commentedI'm closing this in favor of #3373258: Allow to select reference method in link field type for internal links. Because it implements the entity reference selection plugin it inherently includes the ability to select bundles. Also, the MR in the other issue has a few advantages. It's a more complete patch. It's consistent with the way that the
EntityReferenceItemclass works instead of being a unique implementation. And it has tests.Credit has been granted to everyone who worked on the patch in this issue. Thank you for your contributions!