Just installed the rc7, and have an exposed filter which should allow multiple choices for the filter. So, in the hierarchical settings for the filter, I have:

Dropbox settings
[checked on] Enable the dropbox
Title: [no title specified... this is blank]
Limit the number of selections: [default value of zero]
Reset selection of hierarchical select:
Disabled
[set] Enabled

Nonetheless, there is no "Add" button as there was in previous incarnations to add multiple items to the filter. What am I doing wrong?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
Status: Active » Postponed (maintainer needs more info)

Could you please save the HS config again? Then the view's config will be updated as well. The way this works has been changed: it's much more reliable in RC7 than in previous releases, because it directly alters the DB instead of asking the user to submit the views form.

If that doesn't work, you've probably found a bug in the direct DB manipulation process.

EDIT: I just tested this on my test site and here it does work. So if this doesn't work for you, you should also give me FTP + Drupal admin access. I sincerely hope it does work for you.

sdsheridan’s picture

Just so I'm clear, which HS config am i saving again? There's the one for the taxonomy, the once for the CCK Content Taxonomy field in the node-type itself, and the one in the view. Or am I doing all three? If so, does the order matter?

shawn

Wim Leers’s picture

Only the one or ones (you could have multiple HS-powered exposed filters) for the view matter. And no, the order doesn't matter.

sdsheridan’s picture

OK, tried re-saving, and no joy. No add button. I'll send you a log-in and URL info via your contact form.

Wim Leers’s picture

Ugh :(

Ok.

sdsheridan’s picture

Any progress, Wim?

Wim Leers’s picture

I've been studying for my macroeconomics exam of tomorrow, so I haven't had the time. I will look at your site tomorrow or the day after that.

sdsheridan’s picture

Great! and good luck with the exam. :-)

shawn

sdsheridan’s picture

Did a little investigating, and found something interesting:

  1. When configuring the HS Exposed Filter, $config['config_id'] in function hierarchical_select_process has the value content-taxonomy-views-userNodeInfo-field_profiledetails_location, which corresponds to the row with name hs_config_content-taxonomy-views-userNodeInfo-field_profiledetails_location in the variables table. The row is there, and the values correspond to the form. So the configuration form seems to be working as it should.
  2. However, when viewing the view, $config['config_id'] in function hierarchical_select_process has the value content-taxonomy-views-userNodeInfo-4. No row in the variables table starting with "hs_config_" matches this value.
  3. My main view is a views-fusion view, and so this same variable in the views-fusion view is reported as content-taxonomy-views-userlist-4. "userlist" is the name of the main view.

Hope this helps...

@wim: my debug "drupal_set_message" calls are still in the hs.module file on my site. That's how I investigated this.

shawn

Wim Leers’s picture

Status: Postponed (maintainer needs more info) » Active

Interesting. This probably means that the cause is Views Fusion, which would make sense, since you're the only one with this problem.

I'll see if I can make the code that builds the config_id more robust so that it can still work in a Views Fusion environment.

Thanks sdsheridan. This really saves me a lot of time :) I know exactly where to look now. Will be solved tomorrow night.

sdsheridan’s picture

No worries. Note that in point #2 above, that particular view is the non-fused one. It's just the view of #1 but in view-mode, not edit/config-HS mode. It still has the wrong value for the config_id, with a '4' instead of 'field_profiledetails_location'.

shawn

sdsheridan’s picture

OK, found (and think have the fix) for one defect. In function hs_content_taxonomy_views_form_alter within the hs_content_taxonomy_views.module file, line 84 reads:

          hierarchical_select_common_config_apply($form["filter$id"], "content-taxonomy-views-$view->name-$vid", $defaults_override);

and should read (i think)

          hierarchical_select_common_config_apply($form["filter$id"], "content-taxonomy-views-$view->name-$field_name", $defaults_override);

with $field_name instead of $vid.

That gets rid of the problem in point 2 in #9 above, and also the correct field name is showing up for point 3 with this change, even though the view-name part within the $config_id variable is still not matching. So, for the point 2 view, the add button now shows up, as it should.

Point 3 is I believe, and as you suspect, Wim, because of Views Fusion.

Just thought I'd post this further bit of my investigation.

shawn

sdsheridan’s picture

OK, so for problem 3 of #9 above, what about leveraging a function like:


/**
 *  Determine the actual view that defined a filter.
 *
 *  @param
 *    $view - a view object containing the filter
 *  @param
 *    $fieldName - the name of the field that is being filtered
 *
 *  @return
 *    a view object of the filter-defining view, or FALSE if the filter is not defined
 *    in either the main view specified by $view or any of its fused views if module
 *    views_fusion is in stalled.
 *
 **/

function get_defining_view_for_filter( $view, $fieldName ) {

  $sql = "SELECT count(vid) FROM {view_filter} WHERE vid = %d AND field = '%s'";
  
  $found = ( db_result( db_query( $sql, $view->vid, $fieldName) ) > 0 );
  
  if ( $found ) {
    $returnValue = $view;
  }
  else {
    if ( module_exists( 'views_fusion' ) ) {
    
      $sql1 = "SELECT mvid, uses FROM {views_fusion} WHERE vid = %d'";
      $result = db_query( $sql1, $view->vid );
      $returnValue = FALSE;
      
      while ( $row = db_fetch_object( $result ) ) {
        if ( $row->uses == 'nodefamily_parent' &&
              db_result( db_query( $sql, $row->mvid, $fieldName) ) > 0 ) {
            $returnValue = views_load_view($row->mvid);
        }
      }
      
    }
    else {
      $returnValue = FALSE;
    }
  }
  
  return $returnValue;
  
}

and then using this when determining the view name? for example, for line 84 in function hs_content_taxonomy_views_form_alter within the hs_content_taxonomy_views.module:

      $filterView = get_defining_view_for_filter( $view, $field_name );
      hierarchical_select_common_config_apply($form["filter$id"], "content-taxonomy-views-$filterView->name-$field_name", $defaults_override);
sdsheridan’s picture

OK, slightly revised function that is a bit more efficient, and only returns the view name, instead of an entire view object, as that is all that is needed.

/**
 *  Determine the actual view that defined a filter.
 *
 *  @param
 *    $view - a view object containing the filter
 *  @param
 *    $fieldName - the name of the field that is being filtered
 *
 *  @return
 *    a view name of the filter-defining view, or FALSE if the filter is not defined
 *    in either the main view specified by $view or any of its fused views if module
 *    views_fusion is in stalled.
 *
 **/

function get_defining_view_for_filter( $view, $fieldName ) {

  $sql = "SELECT count(vid) FROM {view_filter} WHERE vid = %d AND field = '%s'";
  
  $found = ( db_result( db_query( $sql, $view->vid, $fieldName) ) > 0 );
  
  if ( $found ) {
    $returnValue = $view->name;
  }
  else {
    if ( module_exists( 'views_fusion' ) ) {
    
      $sql1 = "SELECT mvid FROM {views_fusion} WHERE vid = %d AND uses = 'nodefamily_parent'";
      $result = db_query( $sql1, $view->vid );
      $returnValue = FALSE;
      
      while ( $row = db_fetch_object( $result ) ) {

        if ( db_result( db_query( $sql, $row->mvid, $fieldName) ) > 0 ) {
            $sql2 = "SELECT name FROM {view_view} WHERE vid = %d";
            $returnValue = db_result( db_query( $sql2, $row->mvid) );
        }
      }
      
    }
    else {
      $returnValue = FALSE;
    }
  }
  
  return $returnValue;
  
}

which would make the call then look like:

          $filterViewName = get_defining_view_for_filter( $view, "content_$field_name.$field_name".'_value' );
          hierarchical_select_common_config_apply($form["filter$id"], "content-taxonomy-views-$filterViewName-$field_name", $defaults_override);

Question: I had to prepend the field name with "content_", double-up the field name, and append "_value" for this to work; will this construction always be the case?

This makes the add button appear as it should now in both the underlying view and the fused view.

Hope this helps. How do we make it "standard" in HS?

shawn

sdsheridan’s picture

...and now that I got this far, with the "Add" button appearing so i can choose multiple options, it seems as if the filter is "ANDing" all the values, which of course means I get no results, as a node has only one content_taxonomy lineage in the taxonomy, and thus wouldn't have the two or three showing in the filter. In other words, seems the filter is looking for "is all of" as opposed to "is one of".

Also getting double "Remove" labels... one an actual link, the other a checkbox, after the submit of the view comes back.

shawn

sdsheridan’s picture

OK, ignore the "ANDing" problem... that was my own fault in how I set up the view. It's fine.

However, the double "Remove" labels are still there.

sdsheridan’s picture

Had to make a couple more changes to get this to work.

First, the construction "content_$field_name.$field_name".'_value' for the call to get_defining_view_for_filter( $view, "content_$field_name.$field_name".'_value' ) will not always work. It doesn't work when the field is stored in the content_type table. This happens when full lineage is not being stored, and multiple values for the taxonomy are not allowed for the node. However, $filterViewName = get_defining_view_for_filter( $view, $filter['field'] ); will work for both situations.

Secondly, again for the same circumstance where the field is actually stored in the content_type table, the function _hs_content_taxonomy_views_parse_fieldname_from_id needed a second test to pick up the case where $id was of the form "content_type_contenttypename.field_fieldname_value".

/**
 * Given an id of the form "content_taxonomy_<field name>.tid", get the
 * field name.
 *
 * @return
 *   When no valid id was given, FALSE, otherwise the field name.
 */
function _hs_content_taxonomy_views_parse_fieldname_from_id($id) {
  $field_name = FALSE;

  // When "save as tag": content_taxonomy_field_<field_name>.tid
  // Other save options: content_field_<field_name>.<field_name>_value
  if (preg_match("/(content|content_taxonomy)_(field_[A-Za-z0-9_]+)\.(\\2_value|tid)/", $id, $matches)) {
    $field_name = $matches[2];
  }

  // Second test to get field name when field stored in the content_type table.
  elseif ( preg_match("/(content_type_[A-Za-z0-9_]+)\.(field_[A-Za-z0-9_]+)_value/", $id, $matches) ) {
    $field_name = $matches[2];
  }
  return $field_name;
}

With these changes, I now have HS Content Taxonomy working with the Content Taxonomy field on my nodes for location, and in the views filters permitting searches, in both the cases where (a) the full lineage is stored in a table specific to that field, and (b) when only the deepest term is stored in the content_type table, for both a regular view and a views_fusion view.

@Wim: Does this all look "correct" from your perspective? Also, do you feel it should be folded into HS?

shawn

plan9’s picture

Hi Shawn
Which files should your changes be added to?

sdsheridan’s picture

I think I indicated in the various posts which modules / files I was changing, did I not?

shawn

plan9’s picture

Thanks for all your help Shawn

sdsheridan’s picture

No problem. Was a fair bit of detective work to figure this much out.

On a slightly different note, is it just me, or is Wim missing in action?

Wim Leers’s picture

Title: Add button missing when exposed filter set to allow multiple » Content Taxonomy Views config not retrieved properly and Views fusion compatibility
Category: support » bug
Status: Active » Needs work

Yes, I've been very, very absent since September. The reason? University. Sorry about that, but there's only so much time one person has…

I've committed your change for #2. Your proposed changes for #3 look reasonable and logical, but could you please roll them in a single patch so that I've got a better overview. These things are quite hairy :P

http://drupal.org/cvs?commit=180082

Wim Leers’s picture

Status: Needs work » Closed (fixed)

Cleaning up the issue queue. Due to lack of response, I'm closing this issue. Feel free to reopen though! :)

mlncn’s picture

As there has been no stable release yet, here is the fixes for list item 2 issues (non-fusion) in patch form. It also disables the non-javascript fallback, which wasn't working for me and displayed briefly on the page, and changes the "Submit" button to "Go"

This isn't to be committed, but i have it, if some other poor fellow is using Drupal 5 this may help them.

benjamin, agaric