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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook_civicrm_contactListQuery with context 'navigation'
Pages: [1]

Author Topic: hook_civicrm_contactListQuery with context 'navigation'  (Read 421 times)

johanv

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 5
  • #chiro #geek #linux #beer
    • my homepage
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.x
hook_civicrm_contactListQuery with context 'navigation'
February 17, 2014, 05:40:07 am
Hi CiviCRM-community,

If you want to customize the behaviour of the 'quick search box' in the left corner of the navigation menu, you can do this by implementing hook_civicrm_contactListQuery. A lot of tutorials are available on the internet, including this post on the forums.

I guess that most of these howto's were written at the time that there were no 'radio buttons' in the quick search box. Today, if you click the quick search box, you can select the field(s) that should be searched in. Depending on your selection (name/e-mail, civicrm id, external id,...), a query is created.

Now if you implement hook_civicrm_contactListQuery, the search query will be replaced regardless of the selected field. The context parameter always equals 'navigation' if you fired the query from the quick search box.

What I want to achieve, is that when I enter some characters in the quick search box, the name, city and external ID of the contact is shown in the popup list of found contacts. I wonder how I can fix this, without breaking the field selection of the quick search.

Some options:
  • Parsing the original query in hook_civicrm_contactListQuery to figure out what the user is searching for
  • Changing the sort_name of contacts, so that it contains the information I want to be shown. Maybe I can keep this in sync implementing a number of hooks
  • Maybe something else

Any suggestion is much appreciated.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook_civicrm_contactListQuery with context 'navigation'

This forum was archived on 2017-11-26.