1

Is anybody using the json_expand plugin for API functionality? For the entry type Rich Text Field its just returning an empty object.

This is my json_expand endpoint:

{% header "Content-Type: application/json" %}
{% set utensils = craft.entries.section('utensils').find('') %}
{{ utensils | json_expand | raw  }}

It's returning everything except that Rich Text field which just returns this:

"utensil_textbox": {}
Brad Bell
  • 67,440
  • 6
  • 73
  • 143
goran
  • 123
  • 1
  • 1
  • 8

1 Answers1

3

I just came across this problem and solved it by editing the JsonExpandService.php file (located in craft/plugins/jsonexpand/services/) in two places.

Change line 101 from this:

$relatedArray[$subHandle] = $subValue;

To this:

if($subField['type'] == "RichText") {
    // Rich Text field values need to be converted to a string
    $relatedArray[$subHandle] = (string)$subValue;
} else {
    $relatedArray[$subHandle] = $subValue;
}

And change line 115 from this:

$entryData[$handle] = $value;

To this:

if($field['type'] == "RichText") {
    $entryData[$handle] = (string)$value;
} else {
    $entryData[$handle] = $value;
}

This fixed Rich Text fields coming through as empty objects for me.

This plugin hasn't been updated in 3 years, so Craft probably changed something about how Rich Text fields are outputted and the plugin never adjusted. Just a guess.