Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP and Drupal 6 need to talk to each other, but how?

I have a CakePHP app which needs to take data from Drupal (6). Specifically, there is one custom content type and one webform that need to be shared with CakePHP - so when a new node for that content type is added, or a webform submitted, Cake knows about it. I'm not sure the best way to do this, I've come up with two approaches:

  1. Having an alternative datasource for the models in question, and read directly from the Drupal database. However, the Drupal tables are in a Drupally format, which I'd rather not write lots of $this->Model->find()s for - it will be a bit of a pain. I don't totally understand where Drupal stores everything, either.
  2. Writing some code in Drupal to save the data in a different format in the CakePHP database. I don't know how easy this would be - I'm more up to speed with Cake than Drupal. I guess I'd use hook_form_alter and add a function to the $form[#submit] array?

Does anyone have advice about which of these two would be better, or if there's another option? I'm leaning towards the second idea.

Help greatly appreciated, thanks

like image 225
Will Avatar asked Feb 24 '11 15:02

Will


1 Answers

I would create a web services API in Drupal, and periodically run a batch job in Cake which hits the API for new data. Try this module: http://drupal.org/project/services

Or, if you need super-concurrent updates, create an API in Cake to receive data, and a module in Drupal which will send data on submission.

This way you don't need to worry about database-level sharing between the two.

like image 102
yitznewton Avatar answered Nov 18 '22 04:11

yitznewton