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.

Comments

mariagwyn’s picture

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.

mariagwyn’s picture

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!!!

mariagwyn’s picture

Status: Active » Needs review
StatusFileSize
new746 bytes

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!

tinkalink’s picture

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?

diodata’s picture

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:

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.

diodata’s picture

I should add the problem exists in Views 2.8+.

toby.batch’s picture

StatusFileSize
new816 bytes

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

jcamfield’s picture

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.

hachreak’s picture

StatusFileSize
new822 bytes

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

jrc’s picture

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')) {

nicolash’s picture

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.

jcamfield’s picture

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.

dominikb1888’s picture

@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.

jcamfield’s picture

Alright, I'm being dense here. I've applied the patch in #9 against /sites/all/modules/exhibit/contrib/exhibit_views ; edited its first line as per #10, and also applied #3 for good measure. I'm using Exhibit 6.x-1.x-dev and Views 6.x-3.0.

With all of this, I get one working taxonomy selector, but the rest are all NN [Object Object] : http://www.audreyandjon.com/recipes/box

The key seems to be in #3, which only addresses one tid field, whereas my view presents tid, tid_1, tid_2, tid_3....

Any help would be appreciated; my code skills are long rusted over at this level.

jcamfield’s picture

Status: Needs review » Reviewed & tested by the community

Aha! Post-caffeine hacking > pre-caffeine hacking.

Taking the patch from #3 and extending it to cover multiple tids. I'm sure there's a more elegant way to do this, but:

Where this is the #3 patch against sites/all/modules/exhibit/contrib/exhibit_views/views_plugin_style_exhibit_json.inc

      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'];
                }
      }

Add additional


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

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

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

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

Having more tid_Ns does not seem to break the JSON, as they're conditional.