Reputation: 841
I have 2 websites with similar content types.
Let's say an event-content type with some cck fields in it.
site1: events ( title, body, image ) site2: events ( title, body, image, onsite1)
by the extra field at site2-events i want to give the possibility to the user to post his event on the ( main ) site1.
Site1 and site2 are both on 1 database, although tables from site2 are prefixed.
How can i add content made from site2 to site1? ( Is there an easy way to do this without resorting to sql? I am using the nodeapi at this time to do some extra when an event is submitted. )
Upvotes: 2
Views: 2699
Reputation: 391
You might be able to use db_set_active() as Mike-Crittenden describes even if it is within same database, as both $db_url and $db_prefix can be arrays, instead of single strings.
This way you can have the same db_url for both 'default' and 'alternative' db, but use different prefixes to switch between databasees using db_set_active('alternative') and db_set_active() to return to default.
Upvotes: 1
Reputation: 5917
Since you say you're already using hook_nodeapi it seems like you could just do:
if ($op == 'insert' && (see if checkbox is checked here))
...then switch to the other site's database, do a node_save, and switch back to the current site's database to let Drupal finish its business.
Upvotes: 1
Reputation: 6311
Lots of people use Feed API / Feeds module for this. You can filter by taxonomy terms, content type, whatever you need so that you don't have to import everything from the primary site. Great tool.
Upvotes: 0