The autotag module is missing the nice interface that this module has. Is there a way to have, instead of or in addition to popular tags, tags matched from your content show up as you type?

Comments

gagarine’s picture

This module is quite similar and have a "auto tag" feature http://drupal.org/project/tagging. Sadly it doesn't support content taxonomy. The tricky things is you can provide suggestion only after the content is submitted, or perhaps with an ajax call.

Active Tags should provide a hook so other module can provide tag suggestion from content, solr index, views, ...

For reference here the hook of tagging_suggestion (sub-module of tagging).

/**
 * Defining new hook: hook_tagging_suggestion
 * Modules can use this hook to implement their methods to provide suggestions for tagging
 * the current node
 */
function _tagging_add_suggestions($element) {
  // TODO: Quite expensive here. Should we only fetch the body? This might
  // change in the future
  $node = node_load($element['#nid']);
  /*
  * @vid: This is the vid the suggestions have been called for. You can use this to decide whether you
  *       want to suggest something or not for this vocabulary
  * @node: This is the complete expanded node object. Use this to e.g. base your suggestions on the body
  *        of the node or the title or whatever you wish on
  */
  $suggestions = module_invoke_all('tagging_suggestions', $element['#vid'], $node);
  drupal_alter('tagging_suggestions', $suggestions);

  // Validation
  if ( !is_array($suggestions) ) {
    $suggestions = array();
    watchdog(WATCHDOG_WARNING, 'Tagging: Could not parse suggestion array - maybe some hooks are out of bound?');
  }
  // Iam not going to hold the devs hand and validate if we got a valid array with #name / #weight
  uasort($suggestions,'element_sort');
  // Only show a maximum ammount of suggesitons
  if(variable_get('tagging_show_max_suggestion', 20) > 0) {
    $suggestions = array_slice($suggestions,0, variable_get('tagging_show_max_suggestion', 20));
  }
  $element['#suggestions'] = $suggestions;
  return $element;
}     
bennos’s picture

feature sounds great.
subscribing

gagarine’s picture

Title: Autotag from content » hook/API for tagging sugestion

I know is not the original feature request but this will open an easy and flexible way to achieve it and much more.

bgilhome’s picture

Status: Active » Needs review
StatusFileSize
new6.74 KB

Here's a patch that implements a hook_tag_suggestions with an AJAX button to add suggestions to the tag field.

The patch is built on top of an entityreference patch from https://drupal.org/node/1912156#comment-7670623.

There's an example hook active_tags_tag_suggestions at the end of the module flle that should be removed.

bgilhome’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev

Oops, forgot to mention it's based on 7.x-2.x.

bgilhome’s picture

StatusFileSize
new9.07 KB

Here's an improved patch which includes a field setting to enable/disable suggestions. Suggested terms provided via the hook can be in the form $name => $score where $score is a weighting between 0 and 1 (1 highest relevance), or as a simple array of tag names, in which case the tags are scored as 0.5.

Once again this patch is on top of the entityreference patch from https://drupal.org/node/1912156#comment-7670623 (sorry!).

zilla’s picture

very interesting - could this hook take over the implementation for another module, such as alchemy if alchemy api and content analysis are providing the suggested keywords/concepts/entitities with scored relevance?

mahyarsbt’s picture

Assigned: Unassigned » mahyarsbt
Issue summary: View changes
Status: Needs review » Fixed
Issue tags: -JavaScript +JavaScript

Thank you for your continued interest in the Active Tags module.

We are excited to announce that the issue you raised has been addressed in the revitalized Active Tags version 1.0.0. This update supports Drupal 9, 10, and 11 and brings a modern interface along with a range of new features to enhance your Drupal tagging experience, including:

  • Enhanced Tag Styling: Enjoy a modern and visually appealing interface for entity reference fields.
  • Dynamic Tag Creation: Flexibly enable or disable tag creation based on your Drupal settings.
  • Support for User Avatars: Display user avatars in tags when using the User entity autocomplete.
  • Efficient Tag Management: Organize tags effortlessly with drag-and-sort functionality, duplicate protection, and multiple selection support.
  • Entity ID Display: Optionally display the entity ID alongside each tag for added clarity.
  • Integration with Key Modules: Seamlessly integrate with Token, Webform, Facets, and Better Exposed Filters for enhanced filtering and autocomplete functionality.

This is just a glimpse of the new capabilities. We encourage you to explore these new features by downloading the latest version. For a full list of features and more details, please visit the Active Tags project page.

mahyarsbt’s picture

Status: Fixed » Closed (fixed)

With the release of Active Tags 1.0.0, we believe this issue has been fully resolved. We invite you to explore the latest version and share any feedback you have.

Thank you for your continued support and contributions to the Drupal community. Together, we can keep improving Active Tags!


Visit the Active Tags project page to stay updated and provide feedback.