I try to attach lastmod field to taxonomy term using following rule:
Get max timestamp from list of all nodes referenced to current term.

/**
 * Implements hook_xmlsitemap_link_alter().
 */
function [my_super_module]_xmlsitemap_link_alter(&$link) {
  if ($link['type'] == 'taxonomy_term') {
    // search for nodes referenced to current taxonomy term
    $nids = db_select('taxonomy_index', 'ti')
      ->fields('ti', array('nid'))
      ->condition('ti.tid', $link['id'])
      ->execute()
      ->fetchAll(PDO::FETCH_COLUMN, 0);
  
    $timestamps = array();
    foreach($nids as $nid) {
      $node = node_load($nid); // Here i have to load node. Why?
      // Always recalculate changefreq and changecount.
      $timestamps = array_merge($timestamps, xmlsitemap_node_get_timestamps($node));
    }
    $link['lastmod'] = count($timestamps) ? max($timestamps) : 0;
  }
}

It's okey but xmlsitemap_node_get_timestamps() doesn't requires full-loaded node at all. It's enough just node->nid as argument.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

holdmann’s picture

holdmann’s picture

Status: Active » Needs review

Status: Needs review » Needs work
holdmann’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
holdmann’s picture

Status: Needs work » Needs review
FileSize
2.05 KB

Status: Needs review » Needs work
holdmann’s picture

Status: Needs work » Needs review
FileSize
2.01 KB

Third try

Status: Needs review » Needs work
Anonymous’s picture

Assigned: Unassigned » Dave Reid
Status: Needs work » Postponed (maintainer needs more info)

I think this is a won't fix. Dave Reid, can you please chime in on this?