Sites using the Domain Access module may require Google News Sitemap to filter the sitemap by domain. e.g. www.a.com/googlenews.xml should only contain nodes whose domain source is www.a.com.

I attached two patches (one for .module and one for .install) that accomplish this. If Domain Access is enabled, then the admin screen presents an option to "Filter by domain." Is that's set, then the module will filter the sitemaps by domain.

I made the patches based on 6.x-1.4...
; $Id: googlenews.info,v 1.1.2.1 2009/07/24 19:53:13 davereid Exp $

Comments

dave reid’s picture

The module uses db_rewrite_sql(), so shouldn't domain work with that method?

webastien’s picture

I'm not using D6 module, but on D5 this is the correct way:
The module use db_rewrite_query, so you can add this kind of hook_implementation:

// This function is restricted to googlenews page only for performances
if (@$_GET['q'] == 'googlenews.xml' && module_exists('googlenews')) {
  /**
   * Implementation of hook_db_rewrite_sql().
   */
  function YOURMODULE_db_rewrite_sql($query, $primary_table, $primary_field, $args) {
    if (strpos($query, "SELECT n.nid, n.created, n.title FROM {node} n WHERE n.type IN (") === 0) {
      global $_domain;

      $return = array(
        'join'  => "LEFT JOIN {domain_source} d ON (d.nid = n.nid AND d.domain_id = ". $_domain['domain_id'] .")",
        'where' => "d.nid IS NOT NULL",
      );

      return $return;
    }
  }
}
surgeonbor’s picture

Status: Active » Closed (fixed)

Yes, you're right of course. I used hook_db_rewrite_sql() (thanks for the code, webastein) and it's working nicely. I changed the status to closed.

Exploratus’s picture

Works great!!!!

mattwmc’s picture

So is there a way to create a google news sitemap for each subdomain?

chawl’s picture

@mattwmc, this is what the above "perfectly working" patch does.

@surgeonbor, huge tx really!

mattwmc’s picture

Ok, thanks.

Don't know how I missed that, lol.

One of those days I suppose.