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.

1 Answer 1


I made a content type Newsletters, You could remove the Body field if you want form the Node. I then used Panelizer with nodes to make newsletter like layouts. The content for the node is actually ctools based custom data.

I also made use of a custom html--newsletters.tpl.php file to remove site themeing from the newsletter and apply generic newsletter themeing for the site.

If you got this much working:

  • custom content type (title, optional body)
  • Panelizer enabled, pick a layout (or layouts)
    • enable node_panelizer.
  • un-embed newsletter from site with custom html.tpl.php for the content type (optional)

Then I would make a hook_menu entry for your json service. Just do a node_load on the newsletter node and inspect $page['content'] for your nodes layout and "sections". Just build a json array out of how your page is setup in the page render arrays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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