1

I have a custom search extension for contacts. Search result shows by default "VIEW EDIT" option in "ACTION" Column.

How Can I bring the "MORE" option just like the one appears if I use built in Basic search function from Search menu?

Content of my customsearch.php

        <?php

class CRM_Guestsearch_Form_Search_Guestsearch extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {

      function __construct(&$formValues) {
        parent::__construct($formValues);
      }

      function buildForm(&$form) {
        CRM_Utils_System::setTitle(ts('Recently Registered Guest (Unassigned)'));

        $form->assign('elements', array('name'));
      }

      function summary() {
        return NULL;
        // return array(
        //   'summary' => 'This is a summary',
        //   'total' => 50.0,
        // );
      }

      function &columns() {
        // return by reference
        $columns = array(
          ts('Contact Type') => 'contact_sub_type',
          ts('Name') => 'sort_name',
          ts('Phone') => 'phone',
          ts('Email') => 'email',
          ts('Date of visit') => CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME,
        );
        return $columns;
      }

      function all($offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs = FALSE, $justIDs = FALSE) {

        return $this->sql($this->select(), $offset, $rowcount, null, $includeContactIDs, NULL);
      }

      function select() {
        return "
          contact_a.id                  as contact_id  ,
          contact_a.contact_sub_type    as contact_sub_type,
          contact_a.sort_name           as sort_name,
          phone.phone ,
          email.email  ,
          date.
        " . CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME;
      }

      function from() {
        return "
          FROM      civicrm_contact contact_a
          LEFT JOIN civicrm_activity_contact a ON (a.contact_id = contact_a.id)
          LEFT JOIN civicrm_phone phone ON (phone.contact_id = contact_a.id)
          LEFT JOIN civicrm_email email ON (email.contact_id = contact_a.id)
          LEFT JOIN " . CIVICRM_GUESTSEARCH_CUSTOM_TABLE_NAME . " date ON (date.entity_id = contact_a.id)
        ";
      }

      function where($includeContactIDs = false) {
        $params = array();

        $where = "contact_a.contact_sub_type = 'Guest' AND activity_id IS NULL ORDER BY date." . CIVICRM_GUESTSEARCH_CUSTOM_COLUMN_NAME . " ASC ";
            return $where;
          }

      function templateFile() {
        return 'CRM/Contact/Form/Search/Custom.tpl';
      }
    }

1 Answer 1

2

The custom search interface does not implement an API for those actions as yet. I dont think those are hookable right now, but I suspect the best first step would be to modify the code (and submit the patch back) to make those actions hookable.

Once that is done, it should be relatively easy, for the custom search interface to expose the hook as an API

3
  • Thanks Lobo. I will look into that. Another point related to above codes. On civicrm 4.6, when I manually select a result by using the checkbox, ACTION MENU (below search parameters) remains deactivated. Action options only activates if i select the option "Select ALL Records". How can I fix it Please?
    – Tapash
    Commented Apr 15, 2015 at 7:46
  • That seems like a bug. can you please try and reproduce this on our demo servers Commented Apr 15, 2015 at 15:28
  • I think its more like my script than bug, bcos all other searches are working perfectly fine, in terms of selecting few contact from result and execute an action based on that. Do you see anything in my script that can be adjusted to work?
    – Tapash
    Commented Apr 16, 2015 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.