Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#4727 closed enhancement (fixed)

Suggest/autocomplete tags based on previously used tags

Reported by: PStamatiou Owned by:
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.3
Component: General Keywords:
Focuses: Cc:


When using tagging in 2.3, I think it would be great to autocomplete or suggest tags live so that users know tags they have used previously and don't end up with a "Web Dev" tag and a "webdev" tag, other similar but off-by-one tags, etc.

Hopefully that makes sense. I have attached a crude mockup. As you type a box would appear below, with possible matches with the number of times the user has used that tag before in parens. This will help the user know which tag they should use to eliminate having tag dupes.

Attachments (4)

tagging_suggest_mockup.jpg (35.0 KB) - added by PStamatiou 10 years ago.
delicious_tags.png (18.0 KB) - added by PStamatiou 10 years ago.
del.icio.us also does this
grouptags.php (26.5 KB) - added by jhodgdon 10 years ago.
Group Tags plugin (GPL) with type-ahead tag lookup functionality
tagsection.php (11.5 KB) - added by jhodgdon 10 years ago.
New plugin to implement some functionality (see comment below)

Download all attachments as: .zip

Change History (18)

10 years ago

del.icio.us also does this

#1 @Nazgul
10 years ago

  • Milestone changed from 2.3 (trunk) to 2.4 (future)

#2 @darkdragon
10 years ago

  • Keywords hunted-sendnext added

Suggest this be pushed to next release.

#3 @jhodgdon
10 years ago

  • Cc jhodgdon added

I wrote some JQuery code to do this recently. It's in a not-quite-ready-for-public-release (but GPL) plugin that I did for a client, currently acting upon a field in a custom section of the post edit screen, rather than the default WP tag field.

Apparently Matt may have implemented this already? If not, I can turn it into a patch. I'll stay tuned...

#4 @jhodgdon
10 years ago

After a conversation with Matt, I am going to work up a new and improved tag entry section with the following features, derived from some GPL plugins I've already written:

  • Box for typing in tags, with Add button next to it. With type-ahead to suggest existing tags.
  • When you click Add, the tag(s) you entered appear below in a section labeled "Tags used on this post". Each one has a little "x" icon next to it, which you can use to remove that tag.
  • Both Add and Delete functionality use AJAX.

#5 @jhodgdon
10 years ago

Well, this may take more time than I have in the next few days... happy to send the plugins to anyone else who wants to take a whack at it...

#6 @lloydbudd
10 years ago

  • Keywords hunted-sendnext removed
  • Priority changed from lowest to normal
  • Severity changed from trivial to normal

jhodgdon, why not just attach the plugin for now?

#7 @jhodgdon
10 years ago

OK. It would need parts of 2 GPL plugins.

One is Advanced Tag Entry, available for download from this web page: http://poplarware.com/tagplugin.html -- that plugin has functionality around (a) getting the list of all tags in the DB (b) attaching and detaching tags to the post from the DB (c) adding new tags to the DB (using AJAX)

The other isn't "out for public consumption and support" yet (if ever), so I'll attach it shortly. It's called Group Tag Entry, and the functionality needed from there is type-ahead -- when you type tags into the "free tag entry" field on the edit screen, it suggests tags from the DB, which you can then select by clicking on the pop-up list.

Note that except for adding new tags to the DB, all of the dynamic functionality is pure JavaScript, not AJAX. Anyway, for purposes of this project, the "add tags to the database" part could wait until the post is saved and forego AJAX.

I think for me, the easiest way to approach this project would be to merge parts of these two tags into a new plugin with the specified functionality. Adding it to the core is somehow more difficult for me to conceive -- I'm not sure where to put all the pieces, such as JavaScript functions needed, etc. I might be able to get back to it later this week or sometime soon, but other work is calling, sorry!

10 years ago

Group Tags plugin (GPL) with type-ahead tag lookup functionality

10 years ago

New plugin to implement some functionality (see comment below)

#8 @jhodgdon
10 years ago

OK, I just added a new attachment, tagsection.php -- this has the following functionality, implemented as a plugin:

a) Hides the existing tag entry field on the post edit screen.

b) Adds a new section for entering tags.

c) In new section, tag entry field does "type-ahead": as you type tags, a list of suggestions pops open, and you can click on an entry to select it.

d) When you click the "add" button next to the tag entry field, tags are attached to the post (actually they are just put into the hidden main tag entry field, and when the post is saved, they are added).

e) Tags currently on the post are shown below the Add field/button. Each has a delete button next to it that allows you to remove it from the post.

I wrote this as a plugin, not a patch on the WP code itself. Maybe someone can turn it into a patch on the WP code? I wasn't sure where to put the JS stuff...


#9 @jhodgdon
10 years ago

By the way, see also #5156

#10 @matt
10 years ago

Working on this...

#11 @matt
10 years ago

jhodgdon, thanks a ton for posting the plugin. It helped a lot!

#12 @jhodgdon
10 years ago

No problem.

I did want to add one comment: before committing something like this to WP, it would be a good idea to test it on an installation with a lot of tags in the DB. I got a report recently with Advanced Tag Entry that its JS was loading slowly from someone who had hundreds of tags. The code I posted has some similarities, so could have similar issues. Perhaps AJAX could be used to get the tags in the type-ahead, to avoid loading them all initially?

#13 @jhodgdon
10 years ago

Ah, looks like a preliminary version has been committed: [6542] - anyway, I still suggest testing on an installation with a lot of tags in the DB. Looks like your version might avoid the issues mine did, but I haven't read through the code carefully enough to be sure.

#14 @jhodgdon
9 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Note: See TracTickets for help on using tickets.