0

I have two sites.one is Drupal site (example1.com). It has a lot of comments. I want to embed all these comments and comment form to other site (example2.com)[non-Drupal site].

Is it possible?

  • Which Drupal version? – No Sssweat Jan 11 '17 at 7:13
  • using drupal 7. – udhaya kumar UK Jan 11 '17 at 8:16
  • Well since you want to embed them, the only possible way would be using an iframe. You would have to create a view that contains your comments and add the comment box with php. Then you could modify your template files so the headers and footers of your site do not show up at that view page. – No Sssweat Jan 11 '17 at 8:19
  • can you explain birefly. – udhaya kumar UK Jan 11 '17 at 8:27
  • Actually, @Robin is correct, using REST is the better/best way. Because with iframe you will end up with a scroll bar inside your iframe since you need to set a fixed height which will look ugly. – No Sssweat Jan 11 '17 at 8:34
1

I think the best solution is to expose the comments as a REST resource on example1.com. You can achieve this with the services module (you will probably have to create a custom resource).

Then on example2.com execute a GET request on the REST resource and display the comments.

Edit: If you want to fetch the comments per node you will have to add a query param to the resource containing the node ID for which you want to fetch the comments.

| improve this answer | |
  • can i submit comment from example2.com. if possible then how to put comment based on nodes. because i have 100 nodes. how to put comment for particular node. – udhaya kumar UK Jan 11 '17 at 8:41
  • I edited my answer. And yes it is possible to submit a comment on example2.com and save it on example1.com. You will have to add a POST request to your resource which then creates and saves a comment. Then on example2.com execute a POST request to example1.com – Robin Jan 11 '17 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.