Skip to main content
edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Source Link

Building a simple webservice

I need to build a simple JSON webservice for an iPhone application and i would like to give drupal a go :)

Here is the content structure i need, admins should be able to create a Newsletter a news letter should contain (title, description, categories) and then it should be possible to create "news sections" each section should contain (title, text, image) so a section is a group of content and it should be possible to create multiple sections in a newsletter.

First question: how would you structure the above content ? i tried two ways of doing it

  1. created two content types "Newsletter" and "News section" and inside the News section i created a entity_reference to the parent newsletter. works fine, but its not so nice for the admins as they cant really get a overview of what their newsletter is when editing because the content is separated into multiple nodes. also the admins cant sort them.
  2. created a single Newsletter and added the module "field_collection_item" where i setup the "section" fields. This works quite well since it gives the admin a nice way of getting an overview of all the content of the newsletter. But to be honest it looks very messy the admin interface. And i feel like this is a "wrong way of doing it"

When structure is sorted i would like to expose the data as JSON, i found the Services module which seemed perfect. But i have alot of problems exposing the related data, for example if i like to expose a newsletter i would like that all the related news sections is included in the export, but only the id's are exported, i tried alot with Views etc. but cant get it to work properly so i ended up writting a custom hook which looks up the related content. Again i feel like im missing a better way of doing things.

Im very new to drupal so im hoping to get a bit of feedback on how i could build this very simple service in a nice and clean way that makes in intuitive for the admins to administrate the newsletters.