CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Civicrm 4 Drupal 7: How to do multi-value filter with views contextual filters
Pages: [1]

Author Topic: Civicrm 4 Drupal 7: How to do multi-value filter with views contextual filters  (Read 2764 times)

pamreed

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.04
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.3
Civicrm 4 Drupal 7: How to do multi-value filter with views contextual filters
July 30, 2011, 07:10:39 pm
Hi
I have a civicrm custom field that is a multi checkbox that I need to filter the contact members with.
Details:
Custom field: photography_type - checkbox with values of Wedding|13, Baby|15 etc
Create view selecting Civicrm Contact
  Added the fields needs Contact Name, City, Photography Types.
  Added the filters needs
  Setup Contextual filters - pickup Civicrm Custom Photography Type
  Setup the path to have the % on the end.
Now if a contact member has multiple photograph types checked I can not get any results.
I see these issues.
1. If pass the checkbox field label like Wedding it is not changing it to the key value so not results, the data has the key values store as a list for the contact.
2. If pass the key value of 13 for wedding only getting contacts with only Wedding type not all contacts with multiple photography types checked.
To me it looks like it needs to change the query to use a like

Here is the sql query with Wedding passed as the label.

SELECT civicrm_contact.id AS id, civicrm_contact.display_name AS civicrm_contact_display_name, civicrm_address.city AS civicrm_address_city, civicrm_address.state_province_id AS civicrm_address_state_province_id, civicrm_value_member_type_1.photography_type_1 AS civicrm_value_member_type_1_photography_type_1, civicrm_value_member_type_1.region_4 AS civicrm_value_member_type_1_region_4
FROM
{civicrm_contact} civicrm_contact
LEFT JOIN {civicrm_membership} civicrm_membership ON civicrm_contact.id = civicrm_membership.contact_id
LEFT JOIN {civicrm_address} civicrm_address ON civicrm_contact.id = civicrm_address.contact_id
LEFT JOIN {civicrm_value_member_type_1} civicrm_value_member_type_1 ON civicrm_contact.id = civicrm_value_member_type_1.entity_id
WHERE (( (civicrm_membership.membership_type_id IN  ('1', '2')) AND (civicrm_membership.status_id IN  ('1', '2', '3')) AND (civicrm_address.location_type_id IN  ('6')) AND (civicrm_value_member_type_1.photography_type_1 = 'Wedding Photographers') ))


Here is the sql with passing key 13 for wedding
SELECT civicrm_contact.id AS id, civicrm_contact.display_name AS civicrm_contact_display_name, civicrm_address.city AS civicrm_address_city, civicrm_address.state_province_id AS civicrm_address_state_province_id, civicrm_value_member_type_1.photography_type_1 AS civicrm_value_member_type_1_photography_type_1, civicrm_value_member_type_1.region_4 AS civicrm_value_member_type_1_region_4
FROM
{civicrm_contact} civicrm_contact
LEFT JOIN {civicrm_membership} civicrm_membership ON civicrm_contact.id = civicrm_membership.contact_id
LEFT JOIN {civicrm_address} civicrm_address ON civicrm_contact.id = civicrm_address.contact_id
LEFT JOIN {civicrm_value_member_type_1} civicrm_value_member_type_1 ON civicrm_contact.id = civicrm_value_member_type_1.entity_id
WHERE (( (civicrm_membership.membership_type_id IN  ('1', '2')) AND (civicrm_membership.status_id IN  ('1', '2', '3')) AND (civicrm_address.location_type_id IN  ('6')) AND (civicrm_value_member_type_1.photography_type_1 = '13') ))

I am using Drupal 7.4, View 3.0-rc1, and Civicrm 4.0.4.

If anyone could help that be greater appreciated. Let me know if you need more information.

Thank you,
Pam

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Civicrm 4 Drupal 7: How to do multi-value filter with views contextual filters
July 31, 2011, 06:13:47 am
Not 100% sure what you're trying to do, but it seems you need a "one of" setting. Notice that you have in the SQL "civicrm_membership.membership_type_id IN  ('1', '2'))"

I think you need something like "civicrm_value_member_type_1.photography_type_1 IN( '13', '15') "

Perhaps using the same setting as you have for membership type will work. A bit hard to say without seeing the View...
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Civicrm 4 Drupal 7: How to do multi-value filter with views contextual filters

This forum was archived on 2017-11-26.