3
votes

I have a Drupal 6 view that has several arguments. I want to add each unique set of arguments / page to the sitemap created by the XML Sitemap module in Drupal. I have a custom module that creates a menu item for each possible argument combination that is passed into the view, as there are a finite number of them.

I tried following these directions: http://drupal.org/node/507674 but that didn't work.

I then tried to add these links programmatically using this excellent comment: http://drupal.org/node/711100#comment-3150592

However, of the 150+ links I create in a loop of calls to xmlsitemap_link_save(), only 1 was ever saved. The link entry did not possesses any unique characteristics I could detect when compared to other entries that did not get added to the site map.

I build all the links in an array $links. Here is a typical array entry:

$links[] = array(
    'type' => 'mymodulename',
    'id' => '3000-10000',
    'loc' => 'washington-dc',
    'lastmod' => time(),
    'changefreq' => 4600,
    'priority' => 0.5,
);

I am trying to describe the URL:

example.com/washington-dc/3000-1000

I then loop the entire $links array to save each link:

foreach($links as $link) {
    xmlsitemap_link_save($link);
}

Finally, all of this code is in the function:

mymodule_xmlsitemap_links()

which I call from hook_cron:

function mymodule_cron() {
    mymodule_xmlsitemap_links();
    return true;
}

I have confirmed that:

  • My hook_cron() is called during cron
  • Only one link from $links is saved
  • The setting for total number of links to process in the sitepmap module settings is 250, more than enough for my $links array (~150) and the existing site map (47 links)
  • The log shows the XML sitemap generation running and no errors are reported

Any idea what I'm doing wrong?

1

1 Answers

0
votes
'id' => 'Unique ID'  
'loc' => 'example.com/washington-dc/3000-1000', Full path.