function xmlsitemap_term_xmlsitemap_links in XML sitemap 5.2
Same name and namespace in other branches
- 5 xmlsitemap_term/xmlsitemap_term.module \xmlsitemap_term_xmlsitemap_links()
Implementation of hook_xmlsitemap_links().
File
- xmlsitemap_term/
xmlsitemap_term.module, line 164 - Adds taxonomy terms to the sitemap.
Code
function xmlsitemap_term_xmlsitemap_links() {
$excludes = array();
$result = db_query("SELECT vid FROM {vocabulary}");
while ($vocabulary = db_fetch_object($result)) {
if (variable_get('xmlsitemap_term_vocabulary_priority_' . $vocabulary->vid, 0.5) < 0) {
$excludes[] = $vocabulary->vid;
}
}
if (empty($excludes)) {
$excludes = array(
0,
);
}
$tid = 0;
$frontpage = explode('/', drupal_get_normal_path(variable_get('site_frontpage', 'node')));
if (count($frontpage) == 3 && $frontpage[0] == 'taxonomy' && $frontpage[1] == 'term' && is_numeric($frontpage[2])) {
$tid = $frontpage[2];
}
elseif (count($frontpage) == 2 && $frontpage[0] == 'forum' && is_numeric($frontpage[1])) {
$tid = $frontpage[1];
}
$query_args = array_merge($excludes, array(
$tid,
));
$result = db_query(db_rewrite_sql("SELECT t.tid, t.vid, v.module, xt.last_changed, xt.previously_changed, xt.priority_override\n FROM {term_data} t\n LEFT JOIN {vocabulary} v ON t.vid = v.vid\n LEFT JOIN {xmlsitemap_term} xt ON t.tid = xt.tid\n WHERE (t.vid NOT IN (" . xmlsitemap_placeholders($excludes, 'int') . ") AND xt.priority_override IS NULL OR xt.priority_override >= 0)\n AND t.tid <> %d\n GROUP BY t.tid, t.vid, v.module, xt.last_changed, xt.previously_changed, xt.priority_override", 't', 'tid'), $query_args);
while ($term = db_fetch_object($result)) {
$path = taxonomy_term_path($term);
$alias = drupal_lookup_path('alias', $path);
if ($alias === FALSE) {
$alias = NULL;
}
$url = xmlsitemap_url($path, $alias, NULL, NULL, TRUE);
$age = REQUEST_TIME - $term->last_changed;
$interval = empty($term->previously_changed) ? 0 : $term->last_changed - $term->previously_changed;
if (isset($term->priority_override)) {
$priority = $term->priority_override;
}
else {
$priority = min(variable_get("xmlsitemap_term_vocabulary_priority_{$term->vid}", 0.5), 1);
}
db_query("INSERT INTO {xmlsitemap} (loc, lastmod, changefreq, priority) VALUES ('%s', %d, %d, %f)", $url, $term->last_changed, max($age, $interval), $priority);
}
}