How do I add a view to a Sitemap generated by a Drupal Sitemap XML module?

I have a Drupal 6 view with a few arguments. I want to add each unique set of arguments / page to the Sitemap created by the Drupal Sitemap XML module. I have a custom module that creates a menu item for every possible combination of arguments that is passed to the view since there are a finite number of them.

I tried following the following guidelines: http://drupal.org/node/507674 but this did not work.

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

However, of the 150+ links that I create in the xmlsitemap_link_save () call loop, only 1 was saved. The link to the link did not have unique characteristics that I could detect compared to other elements that were not added to the site map.

I am building all the links in the $ links array. 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 a url:

example.com/washington-dc/3000-1000

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

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

Finally, all this code is in a 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
  • Setting the total number of links for processing in the settings of the sitepmap module is 250, which is more than enough for my $ links array (~ 150) and the existing site map (47 links)
  • , XML Sitemap,

, ?

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

Source: https://habr.com/ru/post/1794477/


All Articles