You are here

function xmlsitemap_taxonomy_cron in XML sitemap 6

Same name and namespace in other branches
  1. 6.2 xmlsitemap_taxonomy/xmlsitemap_taxonomy.module \xmlsitemap_taxonomy_cron()
  2. 7.2 xmlsitemap_taxonomy/xmlsitemap_taxonomy.module \xmlsitemap_taxonomy_cron()

Implementation of hook_cron().

File

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

Code

function xmlsitemap_taxonomy_cron() {
  if (($limit = variable_get('xmlsitemap_cron_limit', 100)) != -1) {
    $sql = "SELECT t.tid, t.vid FROM {term_data} t\n      LEFT JOIN {xmlsitemap_taxonomy} xt ON xt.tid = t.tid\n      WHERE xt.tid IS NULL";
    $result = db_query_range($sql, 0, $limit);
    $sitemap_changed = FALSE;
    while ($term = db_fetch_object($result)) {
      $row = new stdClass();
      $row->tid = $term->tid;
      $row->vid = $term->vid;
      $row->changed = REQUEST_TIME;
      drupal_write_record('xmlsitemap_taxonomy', $row);
      $sitemap_changed = TRUE;
    }
    if ($sitemap_changed) {
      xmlsitemap_flag_sitemap();
    }
  }
}