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) »
  • Need help with hook for quicksearch
Pages: [1]

Author Topic: Need help with hook for quicksearch  (Read 930 times)

conwayjm

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6.20
  • MySQL version: 5
  • PHP version: 5
Need help with hook for quicksearch
March 10, 2011, 01:00:07 pm
I am very new to Drupal and CiviCRM, so please forgive me for me lack of understanding. I work for a small environmental non-profit (read 10 people in a office with no budget for IT help) that is trying to setup CiviCRM to handle our membership. We love what we have been able to do so far but really wish that we could quicksearch by external id.

I found a previous post that said this could be done with a hook. Great, so I followed the instructions for implementing a hook by uploading a .info and .module file and then enabling the module through Drupal. However, when I try to search by external id no results are returned and it says no name or email to match ...(external id).

Here is the code I have in the .module file. Disclaimer I am not a coder by trade and welcome all improvements. Actually I found this code through a Google Search (see: Mantra IT site) Thank you in advance for any help you can provide.

<?php

function hook_civicrm_contactListQuery( &$query, $name, $context, $id ) {
 if ($context == 'navigation') {
     $query = "SELECT cc.id as id, CONCAT_WS( ' :: ', sort_name,  email, phone, street_address, city, ste.name, coy.name ) as data, sort_name
               FROM civicrm_contact cc
               LEFT JOIN civicrm_email eml ON ( cc.id = eml.contact_id AND eml.is_primary = 1 )
               LEFT JOIN civicrm_phone phe ON ( cc.id = phe.contact_id AND phe.is_primary = 1 )
               LEFT JOIN civicrm_address sts ON ( cc.id = sts.contact_id AND sts.is_primary = 1)
               LEFT JOIN civicrm_state_province ste ON ( sts.state_province_id = ste.id )
               LEFT JOIN civicrm_country coy ON ( sts.country_id = coy.id )
               WHERE sort_name LIKE '%$name%' OR external_identifier LIKE '%$name%'
               AND cc.is_deleted = 0
               LIMIT 0,10";
    }
   
}

abeverley

  • I’m new here
  • *
  • Posts: 12
  • Karma: 3
  • CiviCRM version: 4.1.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.49 (Debian)
  • PHP version: 5.3.3 (Debian)
Re: Need help with hook for quicksearch
May 06, 2012, 01:44:07 pm
Okay, so this is an old post, but I came across it when trying to do the same.

I have written a HOWTO here:

http://forum.civicrm.org/index.php/topic,24550.msg103343.html

Andy

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Need help with hook for quicksearch

This forum was archived on 2017-11-26.