I'm using the nodewords_bypath module. The problem with it is that it overrides the meta tags that are entered for specific nodes. To fix this I've added some token providing modules to nodewords.module. The code is below. Will this create any problems? Is it useful?

Thanks,
Moses


/**
 * Implementation of hook_token_values().
 */
function nodewords_token_values($type, $object = NULL, $options = array()) {
  if($type = 'node'){
    $tokens['meta-keywords']      = $object->nodewords['keywords'];
    $tokens['meta-description']      = $object->nodewords['description'];
    return $tokens;
  }
  else{
    return;
  }
}

/**
 * Implementation of hook_token_list() for Pathauto specific tokens
 */
function nodewords_token_list($type = 'all') {

  $tokens = array();
  if (module_exists('nodewords_bypath')) {
    if ($type == 'node' || $type == 'all') {
      $tokens['node']['meta-keywords'] = t("The meta keywords");
      $tokens['node']['meta-description'] = t("The meta description");
    }
  }
  return $tokens;

}

Comments

Robrecht Jacques’s picture

Why is there:

  if (module_exists('nodewords_bypath')) {

Can't the tokens be made available even if nodewords_bypath is not enabled?

Why is there:

    if ($type == 'node' || $type == 'all') {

Should something similar not be in nodewords_token_values? I mean: you handle the "all" case here, but not in nodewords_token_values.

Is it possible to always have tokens for all tags? And added to the "global" (or is that "all") token context instead of just "node" context?

Robrecht Jacques’s picture

Status: Active » Needs work
Robrecht Jacques’s picture

Status: Needs work » Fixed

Committed. Will be included in the next release of nodewords (5.x-1.10) released later this week.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.