The interpretation of the error was wrong - se #2 for details.

Have changed the taxonomy but keept the filter. When I now have the same term name the filter sets the default to the old TID (one thats not in use anymore) instead of the terms new TID.

This result in all cases are false in a mandatory filter.

Where is the default TID value stored? I think its might just be to change it in the database.

Comments

RdeBoer’s picture

Hi laghalt,
You can set global filter defaults on the global filter block configuration page, for instance, here: admin/structure/block/manage/global_filter/global_filter_1
Or perhaps you stored the default on your user profile and forgot?

Defaults are be stored in one of three places. You select which of the three here: admin/config/development/session_cache
Rik

laghalt’s picture

Looking more in to it - I seem to be wrong in my teory of why I get a value of 3 or 2 as default (when the TIDs are 29 and 30).

in
$glf_customer = global_filter_get_session_value('customertype');

I used $glf_customer[0] as the value.
Instead it seems like the value is in $glf_customer when a default is loaded and the $glf_customer turns into a array when the visitor choses a value.

I solved this with this code:

  $glf_customer = global_filter_get_session_value('customertype');
    if(is_array($glf_customer)){
     $glf_customer = $glf_customer[0];
    }

Quite a dirty solotion

RdeBoer’s picture

Hi laghalt,
Didn't realise you were retrieve the global filter value through code.
Yeah, if the taxonomy is set up to be multi-select I believe you get an array back from global_filter_get_session_value().

If that's "dirty" then blame core. The Session Cache API used by Views Global Filter simply stores and retrieves the way as it receives them -- like it should.

Rik

laghalt’s picture

Oh, thanks. In fact its a singleselect - but I think its the same to the core. I impressed that the viewfilter manage to handle the difference, working on a module I didn realy like the fact that the data was so diverse. So I change the default into an array - dont know if I break anything.

I did like this in a function that the visitor triggers first:

   $glf_customer = global_filter_get_session_value('customertype');
    if(is_array($glf_customer)){
     $glf_customer = $glf_customer[0];
    } else {
       $new_value = array();
       $new_value[0] = $glf_customer;
       global_filter_set_on_session('customertype',$new_value);
    }

Or - with a little more style (keeping the array in present function):

   $glf_customer = global_filter_get_session_value('customertype');
   if(!is_array($glf_customer)){
      $glf_customer = array(0 =>$glf_customer);
      global_filter_set_on_session('customertype',$glf_customer);
    }
laghalt’s picture

Title: Default stuck on old taxonomy term » global_filter_get_session_value returns value on default and array och userselection

Have change the title to a more corect one

laghalt’s picture

Issue summary: View changes
laghalt’s picture

Status: Active » Closed (fixed)

Im closing it -

one can use my fix.

laghalt’s picture

Title: global_filter_get_session_value returns value on default and array och userselection » global_filter_get_session_value returns diferent value on default and array och userselection
laghalt’s picture

Title: global_filter_get_session_value returns diferent value on default and array och userselection » global_filter_get_session_value returns different value on default and array och userselection
laghalt’s picture

Title: global_filter_get_session_value returns different value on default and array och userselection » global_filter_get_session_value returns different value on default and an array on userselection