From 091a4e17193351058e455fdad42e2d58bf7d4eb7 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Fri, 6 Sep 2019 23:38:15 +0100 Subject: [PATCH] Added doc for hook_civicrm_entityRefFilters --- docs/hooks/hook_civicrm_entityRefFilters.md | 51 +++++++++++++++++++++ docs/hooks/list.md | 1 + 2 files changed, 52 insertions(+) create mode 100644 docs/hooks/hook_civicrm_entityRefFilters.md diff --git a/docs/hooks/hook_civicrm_entityRefFilters.md b/docs/hooks/hook_civicrm_entityRefFilters.md new file mode 100644 index 00000000..46f253a7 --- /dev/null +++ b/docs/hooks/hook_civicrm_entityRefFilters.md @@ -0,0 +1,51 @@ +# hook_civicrm_entityRefFilters + +## Summary + +This hook is called when filters and create links for entityRef field is build. + +## Definition + + hook_civicrm_entityRefFilters(&$filters, &$links) + +## Parameters + +- array $filters - reference to list of filters +- array $links - reference to list of create links + +## Returns + +## Example + + /** + * Implements hook_civicrm_entityRefFilters(). + * + * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_entityRefFilters + */ + function modulename_civicrm_entityRefFilters(&$filters, &$links) { + // Add New Staff link on entityRef field of contact + $links['Contact'][] = [ + 'label' => ts('New Staff'), + 'url' => CRM_Utils_System::url('/civicrm/profile/create', 'reset=1&context=dialog&gid=5'), + 'type' => 'Individual', + 'icon' => 'fa-user', + ]; + + // Add Do not email filter on contact entity ref field. + $filters['Contact'][] = [ + 'key' => 'do_not_email', + 'value' => ts('Do Not Email'), + ]; + // Add Marital status filter on contact entity ref field. + $filters['Contact'][] = [ + 'key' => 'custom_2', + 'value' => ts('Marital status'), + ]; + + // Add custom field of address as filter on contact entity ref field. + $filters['Contact'][] = [ + 'key' => 'custom_34', + 'value' => ts('Belongs to'), + 'entity' => 'Address', + ]; + } diff --git a/docs/hooks/list.md b/docs/hooks/list.md index 1e00112c..d5290640 100644 --- a/docs/hooks/list.md +++ b/docs/hooks/list.md @@ -77,6 +77,7 @@ This is an overview list of all available hooks, listed by category. * **[hook_civicrm_customFieldOptions](/hooks/hook_civicrm_customFieldOptions.md)** - Deprecated in 4.7 in favor of [hook_civicrm_fieldOptions](/hooks/hook_civicrm_fieldOptions.md). Use that instead for modifying all option lists, not limited to custom fields. * **[hook_civicrm_dashboard](/hooks/hook_civicrm_dashboard.md)** - called when rendering the dashboard page and can be used to add content to the dashboard page. * **[hook_civicrm_dashboard_defaults](/hooks/hook_civicrm_dashboard_defaults.md)** - called while a contact views their dashboard for the first time and can be used to enable or disable the set of default dashlets. +* **[hook_civicrm_entityRefFilters](/hooks/hook_civicrm_entityRefFilters.md)** - called when filters and create links for entityRef field is build. * **[hook_civicrm_fieldOptions](/hooks/hook_civicrm_fieldOptions.md)** - allows you to dynamically modify the option list for any field (including custom fields). * **[hook_civicrm_links](/hooks/hook_civicrm_links.md)** - allows you to modify action links including: the actions at the end of a search result row, the Create New dropdown, and the Actions dropdown at the top of a contact record. * **[hook_civicrm_navigationMenu](/hooks/hook_civicrm_navigationMenu.md)** - called after the menus are rebuilt.