0

I'm using RESTws module and access content via /node/id.json. I've written a custom module and use the "hook_entity_property_info" which exposes these fields:

{
  "entity_id": 6655,
  "cloudinary": {
    "publicID": "sdfg334fsdsdfv",
    "title": "test title",
    "caption": "test caption",
    "url": "http://res.cloudinary.com/cloudname/image/upload/asdfd",
    "credit": "© test",
    "keywords": "",
    "description": "sdfgdfsg",
    "primaryImage": "0"
    "width": "300"
    "height": "100"
    "ratio": "1.6"
    "crop": "{'height':100,'width':100,'ratio':1.6}"
  }
}

This works for a node (I can see all my fields). When I use a field collection the module field is completely missing:

{
    "field_answer_v": "test test test",
    "field_correct_v": false,
    "field_feedback_v": null,
    "item_id": "345",
    "revision_id": "345",
    "field_name": "field_answer_fc",
    "url": "http://url/cms/field-collection/field-answer-fc/13085",
    "host_entity": 
    {
        "uri": "http://url/cms/node/3067",
        "id": "3067",
        "resource": "node"
    }
}

When I use "hook_field_collection_item_load", and print the value out in PHP, the module field is there!

"field_cloudinary": {
    "und":[ {
                "publicID":"asdfasdf",
                "title":"test",
                "caption":"",
                "url":"http:\/\/url\/image\/upload\/asdfds.jpg",
                "credit":"\u00a9 ",
                "keywords":"",
                "description":"test",
                "primaryImage":"0",
                "height":"1355",
                "width":"2048",
                "ratio":"0.661621",
                "crop":""
        } ]
},

The data is there but why is it not appearing in the restws module? Is there some other hook I need to use? This is causing some major headaches :-p

5
  • I believe field collections consist of multiple entities. So you fetch the field collection, and you will be presented with more url's to fetch for each of the fields. Mar 26, 2015 at 10:14
  • Have you tried fetching url/cms/field-collection/field-answer-fc/13085 ? I am pretty sure they are there. Mar 26, 2015 at 10:27
  • That's strange. It's been a while since I used restws, but as I remember it, the field collection appeared on the node and then there were more url's to fetch for each of the fields in the collection. But I can't verify that now. Perhaps it gets you somewhere... Mar 26, 2015 at 10:33
  • @Neograph734 I just updated again. When I use hook_field_collection_item_load and echo the content the cloudinary field is there! but it disappears by the time it gets through to restws Mar 26, 2015 at 14:06
  • Got this from the RestWs issue queue: drupal.org/node/1609328. You should be able to construct an url to fetch the data (apparently there is no way to set it). Mar 26, 2015 at 14:11

0

This site is temporarily in read-only mode and not accepting new answers.

Browse other questions tagged .