Download & Extend

Views 6.3-dev + Exhibit Views = JSON error

Project:Exhibit
Version:6.x-1.0-beta1
Component:Data sources
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Using the Views 3.x Dev branch, filter facets break in Views-based exhibits with
n (missing this field) <--as usual
nn [object Object] <-- instead of a list of the objects to filter

Views 2.6 continues to work hunky-dory, but I thought the devs would like a heads-up on an upcoming issue.

AttachmentSize
objectobjecterror.png194.49 KB

Comments

#1

Similar error. Using 'list all terms' in View feed, which displays fine in view. However, in Exhibit, the field '.tid' contains only [object Object].

This error appears on both Views 2.x-dev and 3.x-dev.

2.6 is fine.

#2

any possibility of this being addressed? The views 2.x-dev version has some features I would like to continue to use, so I would prefer not to have to revert to 2.6. But, I am using exhibit for a key page. Any thoughts?

Thanks!!!

#3

Status:active» needs review

A friend a developer came up with a patch which fixes the problem. Not the cleanest, but it works. I have attached it. Improvements welcome!

AttachmentSize
exhibit.patch 746 bytes

#4

Hi,

After installing the patch, I get the error:
warning: Invalid argument supplied for foreach() in ../sites/all/modules/exhibit/contrib/exhibit_views/views_plugin_style_exhibit_json.inc on line 128.
Using php 5.3 and views 6.3-dev

Any ideas?

#5

The warning probably comes in because of the value in the foreach statement is empty. Just check to see if it exists first. The above patch would look something like:

<?php
if ($items[$row->$base_field]['tid']) {
  foreach(
$items[$row->$base_field]['tid'] as $id => $item){
    if(
is_array($items[$row->$base_field]['tid'][$id])){
      
$items[$row->$base_field]['tid'][$id] = $items[$row->$base_field]['tid'][$id]['name'];
    }
  }
}
?>

Of course, this code/patch only works if the base field name within the view is "tid". Many times when creating a view, you bring in taxonomy values multiple times. This would result in the names being tid_1, tid_2, etc... In that case, you would need to repeat the above code, replacing tid with tid_1, and so on. I checked my own sites and usually don't go over tid_4. So, I have this code snippet repeated five times, from tid through tid_4.

This is definitely NOT an ideal solution, or even a good one. But it solves the problem until a new version of the module is released. I'm thinking there will be numerous updates/changes in the new module. Spending a lot of time on creating a patch against the current dev release (May 1, 2009) may not make much sense at this point.

#6

I should add the problem exists in Views 2.8+.

#7

I have a patch that I'm using that works against (potentially) any number of taxonomy (tid) fields

AttachmentSize
exhibit-fixtids.patch 816 bytes

#8

This is still a problem; made more annoying by the Views security release. The patches got me to new and interesting errors claiming that my JSON file was improperly formatted (doesn't seem to be.)

Reverting to good ol' Views 2.6 (http://drupal.org/node/488082) worked.

#9

I have test last submitted patch and comment unknow function "broads_debug_to_syslog".
Now, i think that it correctly use taxonomy.. :-p

AttachmentSize
exhibit-fixtids.patch 822 bytes

#10

There is a similar problem for node reference fields. A simple addition to the first line of the suggested patch appeared to do this trick for me. It just grabs the last three characters of "group_nid" in the feed.

if (!empty($key) && strlen($key)>=3 && (substr($key,0,3)=='tid' || substr($key,-3,3)=='nid')) {

#11

The patch in #9 works. However, can somebody with more Exhibit JS experience say whether it would be possible to solve this via JS? All the taxonomy data is there in the JSON, it just gets wrapped up in a nested element.

"tid":[{"name":"lowitru","tid":"13","vid":"1","vocabulary":"tugilubrip","make_link":true,"path":"taxonomy\/term\/13"}]},

Throwing all the term data away on the PHP level seems the wrong way of going about it...all that extra info could be useful for further custom scripting.

I tried to access the taxonomy term name like this:

ex:columns=".title, .field_date_value, .field_date_value2, .tid[0].name"

but unfortunately that didn't work. The JS syntax is correct, I believe, but Exhibit doesn't seem to support using nested elements for this functionality.

#12

I cannot get #9 to work for me - I'm applying it against exhibit-views.inc, and it throws an error when applied:

Invalid argument supplied for foreach() in .../modules/exhibit/exhibit.views.inc on line 41.

Line 41 in this case is foreach ($items[$row->$base_field] as $key => $value) , using Views 3 alpha4. and the dev branch.

I am using multiple TIDs in my view, however.

#13

@jcamfield: check the patch from #3 it is originally applied to "views_plugin_style_exhibit_json.inc". The patch from #9 works fro me the addtion from #10 as well. Tested and in use in multiple live environments. Needed to apply #9 and #10 manually though.