I realize having autocomplete functionality was requested - #1169630: Linkit-style autocomplete widget - but my organization needs to have something in place sooner rather than later.
I've built out a (dev) module which adds autocomplete functionality to the "Title" of all link fields (at some point, it should be its own separate widget instead of altering the current link widget).
Selecting the node title will fill in the URL with "node/#" (we want to use "node/#" for internal links when possible, which avoids having broken links if a node's alias changes).
Eventually, supporting autocomplete for the URL field should be added, but a core bug (#93854: Allow autocompletion requests to include slashes) needs to be resolved before it will work.
I don't think this makes sense as its own module (I've just built it out this way for now), but it provides a starting point for adding autocomplete functionality.
Comment | File | Size | Author |
---|---|---|---|
#13 | link_autocomplete_2.zip | 3.77 KB | Anonymous (not verified) |
#9 | link_autocomplete.zip | 3.81 KB | dcoulombe |
#7 | link_autocomplete.zip | 3.81 KB | dcoulombe |
#1 | link_autocomplete.zip | 2.76 KB | ccarigna |
link-autocomplete.png | 16.69 KB | ccarigna |
Comments
Comment #1
ccarigna CreditAttribution: ccarigna commentedHere's a .zip in case the .tar.gz file doesn't work.
Comment #2
Kvart CreditAttribution: Kvart commentedThat's something I've also been trying to create. I need this as a separate widget, but I'm stuck with it. Let us know if you find a solution. Thanks for your work!
Comment #3
AdamGerthel CreditAttribution: AdamGerthel commentedI would prefer to see the autocomplete be on the URL field instead. Having the title field for internal autocomplete and the URL field for external as well as internal URLs sounds confusing. Why not just let the URL field be an autocomplete field?
There's a module that does this for menu links: http://drupal.org/project/mpac
Comment #4
McReall CreditAttribution: McReall commentedHi! There are at least two solutions to the autocomplete functionality: CKEditor Link implements it well into CKEditor when looking for an internal path, and a NewCode Blog howto states having solved it for the CCK Link field (I have not verified that).
It would be nice if you could implement such a feature. Thanks.
Comment #5
Danny EnglanderI was looking for this functionality and the module in #1 is almost perfect but I have a static title set so cannot see the autocomplete field as it's on the title field. Would there be a way to set the autocomplete field on the actual link field itself?. I think that would fit more use cases.
@cwc -- Do you have a Sandbox project for this started? Thanks!
Comment #6
askibinski CreditAttribution: askibinski commented#1 is a great usability improvement!
It would be better the other way around indeed, having a autocomplete on the url, and populating the title field if available with the node title. Or - if this is hard - make a extra autocomplete field alltogether which populates the other fields.
Comment #7
dcoulombe CreditAttribution: dcoulombe commented@cwc,
I added the capability for terms and selecting specific content types and vocabularies (or restrict them). So if you need to hide contents from the list, this version will do it:
Comment #8
dcoulombe CreditAttribution: dcoulombe commentedMe again, I switched the autocomplete from the title to the URL as recommended by askibinski.
Comment #9
dcoulombe CreditAttribution: dcoulombe commentedOups... here the file.
Comment #10
lysander19 CreditAttribution: lysander19 commentedThis autocomplete extension is very useful, exactly what we need, thank you!
Comment #11
sunchaser CreditAttribution: sunchaser commentedRunning Link 7.x-1.0
Installed link_autocomplete.zip module from #9
As soon as I start typing in the Link field I get this error :
Comment #12
jcfiala CreditAttribution: jcfiala commentedIf you can come up with this so it's it's own widget, we could work on adding it as an option to the link field, or see if there's a module to put it in.
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedI had the same issues as #11. I added a check on $where_node_type and $where_vocabulary to make sure they have items before adding that as a condition.
Comment #14
rooby CreditAttribution: rooby commentedAny chance someone can make a patch file instead of a zip? It's way easier to review a patch.
This is definitely a useful feature since node reference fields give no control over the link text.
Comment #15
rooby CreditAttribution: rooby commentedAlso, this should be needs review, not active.
Comment #16
Daniel Wentsch CreditAttribution: Daniel Wentsch commentedThanks dcoulombe and r_smylski for this useful helper. It works well and really has deserved a sandbox project imho!
Comment #17
korven CreditAttribution: korven commentedSubscribing!
Comment #18
jcfiala CreditAttribution: jcfiala commentedHave you folks looked at the existing Advanced Link module? I link to it on the front page, and it provides autocomplete functionality already!
Due to that, I'm marking this 'Won't Fix' for now.
Comment #19
marcoka CreditAttribution: marcoka commentedthank you a thousand times for that example code.
FYI well advanced link does something different, you need to manuall add links to a textfield for external and it uses only internal links for autocomplete.
Comment #20
John Pitcairn CreditAttribution: John Pitcairn commentedSee also: CKEditor Link widget
Comment #21
jlyon CreditAttribution: jlyon commented@rsmylski: Thanks, this is a great little module. I tried advanced_link, but it didn't let me run autocomplete on the titles, and provided a lot of extra functionality that I did not need.
I took the liberty of creating a sandbox project: link_autocomplete. If you would like me to transfer ownership or make it a full project, just let me know.
Comment #22
harry_nc CreditAttribution: harry_nc commentedYour best bet with this kind of issue is to use an entity reference field linked to a view that loads just the nodes you want available to be linked to.
Comment #23
rooby CreditAttribution: rooby commentedOnly if you want 2 separate fields for internal & external.
If you want a single field entity reference is no good.
The better solution is mentioned in #18, which is to use the advanced link module that is linked to from the link module project page.
Comment #24
rudiedirkx CreditAttribution: rudiedirkx commentedSandbox in #21 is perfect IF all your nodes are public, because no access check.
Comment #25
marcoka CreditAttribution: marcoka commentedan info for all of you guys trying to do this:
https://www.drupal.org/project/search_autocomplete
that module makes it possible for any field!
example view: http://root.artwaves.de/sharex/2015-04-07_17-23-05.png
example settings: http://root.artwaves.de/sharex/2015-04-07_17-23-24.png
Comment #26
Proteo CreditAttribution: Proteo as a volunteer commentedThank you very much @rsmylski and @jlyon, the sandbox module is perfect for what I needed.