| Project: | Link |
| Version: | 7.x-1.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
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.
| Attachment | Size |
|---|---|
| link_autocomplete.tar_.gz | 2.2 KB |
| link-autocomplete.png | 16.69 KB |
Comments
#1
Here's a .zip in case the .tar.gz file doesn't work.
#2
That'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!
#3
I 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
#4
Hi! 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.
#5
I 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!
#6
#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.
#7
@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:
#8
Me again, I switched the autocomplete from the title to the URL as recommended by askibinski.
#9
Oups... here the file.
#10
This autocomplete extension is very useful, exactly what we need, thank you!
#11
Running 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 :
An AJAX HTTP error occurred.HTTP Result Code: 500
Debugging information follows.
/* some irrelevant parts omited */
ResponseText: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))
LIMIT 10 OFFSET 0' at line 1: SELECT node.nid AS nid, node.title AS title
FROM
{node} node
WHERE (title LIKE :db_condition_placeholder_0 ESCAPE '\\') AND (type IN ())
LIMIT 10 OFFSET 0; Array
(
[:db_condition_placeholder_0] => max%
)
#12
If 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.
#13
I 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.
#14
Any 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.
#15
Also, this should be needs review, not active.
#16
Thanks dcoulombe and r_smylski for this useful helper. It works well and really has deserved a sandbox project imho!
#17
Subscribing!
#18
Have 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.
#19
thank 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.