heypano
heypano

Reputation: 180

How do I create a feed that transfers nodes between Drupal 7 websites?

I have a Drupal 7 website with content types like "events" and "news".

I would like for nodes of these content types to be automatically imported into other websites.

I played with Feeds, XPath on the 'client' websites and Views RSS fields' onn the 'server' side, but I realized that there would be problems with content type fields like files... Any suggestions? I would like to be able to create new views for this content in the other websites.

P.S. The content types will be identical between the websites (but they don't have to, if your solution includes something else).

Upvotes: 3

Views: 1409

Answers (2)

claire
claire

Reputation: 813

Maybe you can just share data by creating xmls/json (server side) that will be used by the client side.

services is a good way to go. But I find it complex for simple stuffs.

What you can do is create views that will output as xml/json... You can do this by doing preprocess functions in your module/template file.

After which the client side (maybe run cron) will take the xml/json and create nodes programmatically.

Upvotes: 1

berkes
berkes

Reputation: 27573

You probably have more success with services and content Distribution. RSS feeds are not well suited for transfer of semantic data. They are highly focused on lists-of-articles and typically lack information such as "event-start-date".

Services allows you to expose services on the server-drupal-site, exposing the nodes as e.g. RESTfull json. The client side-drupalsite can then use services and content-distribution to import nodes from said server.

That said, the services suit plugs into views, and is really heavy, large and complex. If you are allergic to large and complex projects (like I am), you may be better of writing simple modules:

  • events-service: a 20+ lines module that grabs the events from the database, and presents them as json.
  • news-service: a 10+ lines module that fetches a list of news-nodes and presents them as json.
  • events-client: a small module (~400-800 lines?) that eats said json at the given url and turns them into nodes. It will keep a register of some UUID next to the nodes table, to avoid re-creating nodes on changes upstream (but instead finding the associated one and updating that).
  • news-client: a small module. Same as above.

Writing such modules is very rewarding, because instead of fighting with poorly documented views-plugins, complex layers around services and such, you have full control and full understanding. It also allows for a lot better tuning and performance.

The one large downside is that Drupal, more specific: CCK or Fields, dictate the database and its structure. There will be a point when some tiny config change on your site breaks your modules SQL query: all of a sudden you are blasting SQL errors because Drupal decided to rename or move out some table, column or reference.

Upvotes: 1

Related Questions