xml sitemap for pligg v0.7

This is a quick fix for a bug introduced in a previous version because I tried to make it compatible with php4 date().

This bug may have made your sitemap invalid because the lastmod date contained the timezone between the date and time.

This version also brings a new feature that could be useful for larger sites.

The cache

I noticed that on a site with over 20000 links it may take a lot of time to generate the sitemap index and sitemap files and will put some significant load on the server if google, yahoo or ask will try to access the sitemap every few minutes or hours ( depending on your site's posting/pinging frequency ), so I thought it would be nice to have some kind of cache.

The module will save generated sitemap index and sitemaps in pligg's cache directory ( this means it needs to be writable by the user running the webserver ) and if the cache has not expired yet the module will serve the sitemaps from the cache instead of trying to regenerate every time.

You can set the expire time ( TTL ) and the module will regenerate the sitemap if TTL seconds have passed since the last time it was modified.

You don't need to set any cron job to generate the sitemap files. It will only generate the sitemap if someone/something(google,yahoo,ask) tries to access it.

Another modification related to the caching system is that the site will only ping services if the cache has expired so make sure you set your cache's TTL accordingly.

Upgrade:

To upgrade to this version just download and unzip in your module's directory and then to pligg admin -> module management , disable and uninstall the module and then reinstall it so that you can see the new options ( "Use Cache" and "Cache TTL")

Download from module's own page

11 thoughts on “xml sitemap for pligg v0.7

  1. Love the module and have been running for awhile now. Suddenly though, Google is reporting errors in 12 of the 14 site maps I have.

    Here’s the error message:

    All the URLs in your Sitemap have the same priority.
    All the URLs in your Sitemap are set to the same priority (not the default priority). Priority indicates the importance of a particular URL relative to other URLs on your site, and doesn’t impact your site’s performance in search results. If all URLs have the same priority, Google can’t tell which are more important.

  2. Hi,
    I have installed version .9 on my 9.9.5 site and my sitemaps are empty
    There were not being created so I used existing ones and they are not updating.
    Any the people at pligg forums are either unwilling, or unable to help
    Thanks
    Gary

    1. first you have to remove the sitemaps ( the xml files ) you downloaded from my site and uploaded to yours. Why you did that is beyound my understanding. If static xml files already exist with the same name the .htaccess rules might not work.

      Then make sure the .htaccess rules are set as described in the module configuration page.

      If you look at your sitemaps index:
      http://www.levelupster.com/module.php?module=xml_sitemaps_show_sitemap ( this is the index )
      It seems like you have the “friendly sitemaps” option set because index has
      http://www.levelupster.com/sitemap-0.xml (friendly ) instead of
      http://www.levelupster.com/module.php?module=xml_sitemaps_show_sitemap&i=0 ( not so friendly )

  3. Google states that a site map for a news orientated website should only list articles for the past 3 or 4 days, not every post. Is there a way to put a limit?

    1. There’s no such feature in this module but you can modify it easily to make it work like that.
      in xml_sitemaps_main.php look for the function create_sitemaps_index. inside the function definition there should be a line like this:
      $sql = “SELECT count(*) FROM “.table_links.” WHERE link_status!=’discard'”;
      replace it with this:
      $last_days=4;
      $sql = “SELECT count(*) FROM “.table_links.” WHERE link_status!=’discard’ and link_modified > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $last_days DAY))”;

      a few lines down there should be another line like this:
      $sql=”select max(l.link_modified) from (select link_modified from “.table_links.” where link_status!=’discard’ order by link_modified asc limit “.$i*$max_rec.”,$max_rec ) l”;
      replace it with :
      $sql=”select max(l.link_modified) from (select link_modified from “.table_links.” where link_status!=’discard’ and link_modified > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL $last_days DAY)) order by link_modified asc limit “.$i*$max_rec.”,$max_rec ) l”;

      This will make the sitemaps only show links updated in the last 4 days. Want to change the number of days? just assign another value to $last_days in the first replacement.
      I just wrote this here. I didn’t actually test this but it should work.
      Let me know if you have any problems.

Leave a Reply to FabioCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.