When adding folksonomy terms to a node, drawing from existing terms would be a useful feature. There are two options worth considering:

  1. An initially hidden flat list of the most used 150 tags that you can click to add to your text input (see my demo)
  2. A Google-suggest like feature for pulling out of all available tags
CommentFileSizeAuthor
#3 taxonomy_autocomplete.patch2.41 KBkilles@www.drop.org

Comments

factoryjoe’s picture

Project: Folksonomy » Drupal core
Component: User interface » taxonomy.module

This was intended for Morbus' freetagging code, which doesn't have a separate project. Thus, I'm moving it to the drupal project.

killes@www.drop.org’s picture

I think that should be easy once Thox' Ajax code has hit core.
See:
http://drupal.org/node/22471

killes@www.drop.org’s picture

Assigned: Unassigned » killes@www.drop.org
StatusFileSize
new2.41 KB

Ok, somebody please try this patch. You'll need to apply the ajax patch first.

Steven’s picture

Good patch, some niggles:

  • The check_plain() does nothing to either commas or pipes, so you can do it at the end after all the imploding. In fact, you also need to check_plain() the existing words again, so moving the check_plain() to the end fixes that too. The existing words are in plain-text form when they arrive and need to be inserted back into HTML.
  • First you explode by ',' (no space), then you implode by ', ' (with space). It seems to me that each time you use an autocompletion suggestion, you get extra spaces after a comma. It's possible HTML's whitespace rules collapse the multiple spaces, but it needs to be tested.
  • Like the other Ajax patch, we should hardcode $limit to prevent abuse.
Steven’s picture

I've confirmed the "extra spaces after commas" problem occurs. The simplest fix is to just implode and explode the same and ignore whether spaces are correct. They will be trimmed off when the terms are saved anyway.

Also, this bit of code could use a bit of commenting:
// The user enters a comma-separated list of tags. We only autocomplete the last tag.

Steven’s picture

Now superseded by #22519.