Auto-keywords vocabularies is working for terms but not for nodes.

In metatags/keywords.inc
taxonomy_node_get_terms($ids[0]) returns an empty string when it should return an array of terms

I guess it's a module conflict (http://drupal.org/node/152205)

Anyone knows ho to fix this please?

Comments

Bilalx’s picture

Status: Active » Fixed

I found a fix thanx to http://www.drupal4seo.com/web-site-optimization/nodewords.html#comment-9

In metatags/keywords.inc

Replace
foreach (taxonomy_node_get_terms($ids[0]) as $term) {

By
foreach (taxonomy_node_get_terms(node_load($ids[0])) as $term) {

ghostks’s picture

It's not the best way to fix this issue in my opinion - we needn't to load things twice.

function nodewords_keywords_prepare($type, $ids, $value, $settings) {
  if ($type == 'node' && function_exists('taxonomy_node_get_terms') && count($ids) == 1) {
    $node = node_load($ids[0]); 
    if (node_access('view', $node)) {
      foreach (taxonomy_node_get_terms($node) as $term) {
        if (in_array($term->vid, $settings['keywords_vids'])) {
          $value .= ','. $term->name;
        }
      }
    }
  }
  $value .= ','. $settings['global']['keywords'];
  $value = _nodewords_keywords_uniq($value);
  return $value;
}

I've added variable $node to store node info and pass it to the function taxonomy_node_get_terms(). This is small enhancement, but many small enhancement will grow in big benefit ;)

avpaderno’s picture

Status: Fixed » Active

The fixed status means that the issue has been fixed from the maintainer in Drupal CVS, not that somebody has fixed the issue in his own copy of the project module(s).

Robrecht Jacques’s picture

Status: Active » Closed (duplicate)

Duplicate of http://drupal.org/node/270193 which has a patch which has been comitted.