I use a cck text field as the body and a separate cck text field as teaser the teaser of nodes. So "Generation source:" = "node body" or "node teaser" won’t work for me (and I guess, for many other drupal users).

Wouldn’t it be great if one could select any cck field (that is applicable) as source for automatic meta tags content generation?

Comments

melon’s picture

Status: Postponed » Active

I managed to accomplish this by implementing hook_nodewords_tags_alter():

function YOURMODULE_nodewords_tags_alter(&$output, $parameters) {
  if ($parameters['type'] == NODEWORDS_TYPE_NODE && !$output['description']) {
    $node = menu_get_object();
    if ($teaser = $node->field_teaser[0]['value']) {
      $text = trim(preg_replace('/(\r\n?|\n)/', '', strip_tags($teaser)));
      $output['description'] = node_teaser($text, $node->format, variable_get('nodewords_max_size', 350));
    }
  }
}

where $node->field_teaser is the CCK field used for teaser content. This tiny implementation assumes that only one value is set to this teaser field and it only sets the meta description. Please note that this is quite untested yet, and there might be more elegant and less resource extensive solutions as well.

Guo’s picture

any update? I still don't know how to generate meta tags from cck text field...

damienmckenna’s picture

This won't be in the next release, so you should try using the hook described in #2 above.

damienmckenna’s picture

Status: Active » Postponed
damienmckenna’s picture

Status: Active » Closed (won't fix)

I'm going to draw a line in the sand and say that this won't be done, instead I'm going to work on re-adding tokens support: #1380362: Re-implement Token integration