Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi!
I tried to create a JSON view from nodes but result is filled with different field names and just node id as value for each field (except for title and nid).
This problem came up while using raw output which seems to be the key to this problem since changing back to normal output field names and values match again.
Maybe some array gets false indexes while generating raw output?
Also watchdog has some errors:
Couldn't find constant JSON_FORCE_OBJECT @ template_preprocess_views_views_json_style_simple() row 31
Comment | File | Size | Author |
---|---|---|---|
#10 | views_datasource.fix_raw_json_values.2384329_10.patch | 2.51 KB | jacob.embree |
#3 | views_datasource.fix_raw_json_values.2384319_03.patch | 1.37 KB | rfay |
Comments
Comment #1
reb00ter CreditAttribution: reb00ter commentedtrying to make custom template for views row, but for every field of node $field->raw gives me $fields['nid']->raw. $field->content outs correct value, but I need to get not formatted integer value without suffix and prefix
am I doing something wrong?
Comment #2
rfayThis is a major problem, would love to hear if anybody has looked at it. Changing to major, as it makes all raw json with fields unusable.
Comment #3
rfayI'm no views expert, but the code was not reaching into places that work for the raw values.
This patch makes it at least *find* the right values. Reviews and improvement appreciated.
Comment #4
rfayComment #5
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedWorks great!
Comment #6
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commented#3 worked for me as well.
Comment #7
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedIs there a good way to determine which column to return when there is no group_column, such as with image fields? The group_column is set in the field handler's option definition. It looks for a single column or a 'value' column. Fields such as image have more than one column and no 'value' column so the raw value will always be blank.
Comment #8
ZeiP CreditAttribution: ZeiP as a volunteer commentedFixed in #1271506: use field_output: raw get wrong outputs. Thanks!
Comment #9
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedThis patch solves a problem that is not solved by #1271506: use field_output: raw get wrong outputs. In that one the column used to determine the raw value is hard coded. In this one the column is based on the column selected in the view. For example, with this patch one is able to get the raw tid from a taxonomy_term_reference field. With #1271506: use field_output: raw get wrong outputs that is impossible because "name" is always selected.
When this patch is rerolled it would be good to include the changes from https://cgit.drupalcode.org/sandbox-jacob.embree-2838147/commit/?id=4e134d2 and https://cgit.drupalcode.org/sandbox-jacob.embree-2838147/commit/?id=6b1ec98 made in my fork.
Comment #10
jacob.embree CreditAttribution: jacob.embree at St. Louis Integration commentedDoes this work just as well for fields like url, email, and video?