rsanchez / json

Output ExpressionEngine data in JSON format.
http://devot-ee.com/add-ons/json/
101 stars 234 forks source link

Returning Custom Fields #50

Open jledfordtbc opened 9 years ago

jledfordtbc commented 9 years ago

I am not understanding how I can pull in custom fields data. As an example I have a ChannelImages field and it simple pulls in ChannelImages for the data. The document says to specify a channel and I believe I am doing that, but if you could point me in the right direction it would be most appreciated.

my code {exp:json:entries channel="{segment_4}" fields="title|url_title|page_images" limit="10" jsonp="yes" callback="callback"}

rsanchez commented 9 years ago

I’m afraid there’s no support for Channel Images built in. Any custom field that stores its data in a separate database table needs to have an adapter written for it. This is how the built-in support for Matrix and Grid works. I did once receive a pull request that added Channel Files support: https://github.com/rsanchez/json/pull/41 https://github.com/rsanchez/json/pull/41. I’d gladly accept a pull request with Channel Images support.

jledfordtbc commented 9 years ago

Does channel files work without any extra manipulation? Or how do I access the data in that field type? I have that as well and will look at adding a pull request for channel images if I get channel files working.

Thanks.

From: Rob Sanchez [mailto:notifications@github.com] Sent: Tuesday, September 01, 2015 4:31 PM To: rsanchez/json Cc: Jason Ledford Subject: Re: [json] Returning Custom Fields (#50)

I’m afraid there’s no support for Channel Images built in. Any custom field that stores its data in a separate database table needs to have an adapter written for it. This is how the built-in support for Matrix and Grid works. I did once receive a pull request that added Channel Files support: https://github.com/rsanchez/json/pull/41 https://github.com/rsanchez/json/pull/41. I’d gladly accept a pull request with Channel Images support.

— Reply to this email directly or view it on GitHubhttps://github.com/rsanchez/json/issues/50#issuecomment-136852684.

rsanchez commented 9 years ago

You should need to do anything extra to get channel files working, see the output format for channel files in the docs here: https://github.com/rsanchez/json#channel-files

jledfordtbc commented 9 years ago

I apologize if I am being dense. In my output for a channel file field I am just getting "fieldname":[]

No values are coming through on the output. Do I need to specify that fieldname in a fields list and select it specifically in the json:entries line? Thanks in advanced for your help.

rsanchez commented 9 years ago

No, you shouldn't need to. It should just automatically work. The fact that it's coming back to you as an array (albeit empty) and not a string makes me thing that it is indeed passing through the channel files adapter. The Channel Files adapter was written by someone else, so I'm not entirely sure it works. Never used Channel Files myself. You might have to dive into the code to do some debugging.