You are here

function xmlsitemap_taxonomy_nodeapi in XML sitemap 6

Implementation of hook_nodeapi().

File

xmlsitemap_taxonomy/xmlsitemap_taxonomy.module, line 106
Adds taxonomy terms to the sitemap.

Code

function xmlsitemap_taxonomy_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'update':
      $terms = taxonomy_node_get_terms($node);
      foreach ($terms as $term) {
        $result = db_fetch_object(db_query("SELECT tid, changed, previously_changed, priority_override\n          FROM {xmlsitemap_taxonomy}\n          WHERE tid = %d", $term->tid));
        if ($result === FALSE) {
          $row = new stdClass();
          $row->tid = $term->tid;
          $row->vid = $term->vid;
          $row->changed = $node->changed;
          $row->previously_changed = $node->created;
        }
        else {
          $row = $result;
          if ($row->changed < $node->changed) {
            $row->previously_changed = $row->changed;
            $row->changed = $node->changed;
          }
        }
        drupal_write_record('xmlsitemap_taxonomy', $row, $result === FALSE ? NULL : 'tid');
        xmlsitemap_flag_sitemap();
      }
      break;
  }
}