You are here

function nodewords_nodeapi in Nodewords: D6 Meta Tags 6.2

Same name and namespace in other branches
  1. 5 nodewords.module \nodewords_nodeapi()
  2. 6.3 nodewords.module \nodewords_nodeapi()
  3. 6 nodewords.module \nodewords_nodeapi()

Implements hook_nodeapi().

File

./nodewords.module, line 63
Implement an API that other modules can use to add meta tags.

Code

function nodewords_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
    case 'load':
      $output['nodewords']['metatags'] = nodewords_load_tags(array(
        'type' => NODEWORDS_TYPE_NODE,
        'id' => $node->nid,
      ));
      return $output;
    case 'insert':
    case 'update':
      if (isset($node->nodewords['metatags'])) {
        nodewords_save_tags($node->nodewords['metatags'], array(
          'type' => NODEWORDS_TYPE_NODE,
          'id' => $node->nid,
        ));
      }
      break;
    case 'delete':
      nodewords_delete_tags(array(
        'type' => NODEWORDS_TYPE_NODE,
        'id' => $node->nid,
      ));
      break;
  }
}