Could I use TW to read data from another site in my multi-site installation?

Use case: I'm building an internet and an intranet site as two sites in a multi-site configuration. The sites have a shared database, but no shared tables, because nodes and users must not be shared across the sites. Well... except for a list of the 3 most recent news articles on the internet site, which must be shown on the intranet. In the original plans we decided to do that with an RSS feed, but now I found out about TW and I'm really curious wether that would be a better solution. The advantage of TW (compared to feed aggregration) would be that changes on the live site are reflected on the intranet in real time, not after the next cron run.

Thanks in advance for your opinions.

Comments

mikeryan’s picture

Assigned: Unassigned » mikeryan
Status: Active » Fixed

Yes. Please see the documentation at http://drupal.org/node/452374, the Table prefixing section at the end.

marcvangend’s picture

Version: 6.x-1.x-dev » 6.x-1.1-beta1
Category: support » bug
Status: Fixed » Active

Mike, thanks for the answer. I hope you don't mind I'm following up in this same issue with the problems I'm encountering. I'm using TW 1.1-beta1, Views 2.6 and Schema 1.4.

This is now in my settings.php:

$db_url = array(
  'default'  => 'mysqli://username:password@localhost/databasename';
  'internet' => 'mysqli://username:password@localhost/databasename';
);
$db_prefix = array(
  'default'  => 'intra_', // intranet tables are prefixed with 'intra_'
  'internet' => '',       // internet tables are prefixed with 'inter_'
);

On admin/content/tw, the internet tables are shown in the 'add existing tables' fieldset. The table names listed in the #edit-existing-lists-default select box are not prefixed. Tables in #edit-existing-lists-internet are already prefixed with 'inter_'. When I select table 'inter_node' and try to add it, I get a list of error messages, all starting with "user warning: Table 'databasename.intra_inter_node' doesn't exist", originating from different lines (316, 319, 323, 329) in tw.module.

After that, the inter_node table does get listed in the 'tables table' and the correct columns show up on admin/content/tw/analyse/3, but when I reanalyze, the same errors appear.

On admin/content/tw/view/inter_node, I get two errors, again starting with "user warning: Table 'databasename.intra_inter_node' doesn't exist", but this time originating from views/includes/view.inc lines 729 and 755.

I hope I can help you fix this issue as a way to say "thanks for this great module", but right now, I'm not sure in which direction to search for the solution.

marcvangend’s picture

OOPS! I could just edit the above, hope that nobody has seen it, and still look really smart... but I guess I'll just leave it there for future reference :-)
I just noticed that I overlooked an important detail: overwriting the prefix is done on table level, not on db-connection level. So this works:

$db_url = array(
  'default'  => 'mysqli://username:password@localhost/databasename';
  'internet' => 'mysqli://username:password@localhost/databasename';
);
$db_prefix = array(
  'default'  => 'intra_', // intranet tables are prefixed with 'intra_'
  'inter_node' => '',     // internet tables are prefixed with 'inter_'
);
mikeryan’s picture

Status: Active » Closed (fixed)