1

I have an extension that lets people filter contacts in various ways. I'd like them to be able to click to show these contacts in a standard Civi results page - with the action box at the top etc. So that they can manipulate them in the normal ways, by adding to groups and such.

Is there a recommended way to do this, programatically?

  • we have done some work to enable lots of elements be filtered via the url so menu links can be set up - if that sounds useful i will dig out the documentation – petednz - fuzion Jul 19 '18 at 20:13
1

If you rejig your extension so that your filtering is done via "custom search" then you automatically get that. See https://docs.civicrm.org/dev/en/latest/extensions/civix/#generate-search

  • Thanks! Unfortunately that's not quite how my extension works - there's a lot of API work, which custom searches don't like very much. Is it possible to fire a list of contact IDs at a page? – Andrew West Jul 19 '18 at 18:08
  • 1
    I haven't tested this but I suppose you could write a separate very simple custom search which takes as input a comma-separated list of ids, then do a redirect to it from your existing extension with force=1, e.g. CRM_Utils_System::redirect( CRM_Utils_System::url('civicrm/contact/search/custom', "reset=1&force=1&csid={$myCustomSearchId}&inputField={$csvListOfIds}")); where inputField is whatever you call the form field that takes the list of ids in the custom search. You might not even need a field just retrieve directly from the url. It's clunky - maybe somebody else has better. – Demerit Jul 19 '18 at 18:46
  • 1
    You may be able to use the search builder to post a comma separated list of IDs when using the search criteria "contact id IN". – Thomas Schüttler Jul 20 '18 at 8:47
1

Another way would be to use the api in your extension to create a group out of the results, then redirect to the group's group page, which has the same actions dropdown that search results does.

You might end up with a lot of stale groups lying around, but you could have a cron script delete the groups daily or something like that.

1

We have done work that is hopefully heading to Civi core which makes the following possible:

Below is the table of field name vs params that can be used in the URL to force the search results.

Contribution Tokens

Field Name > > Param in URL

contribution_page_id > > pid

financial_type_id > > fid

contribution_status_id > > status

is_pay_later > > pay_later

receive_date_from > > (receive_date) start

receive_date_to > > (receive_date) end

Eg of complete search URL -

"civicrm/contribute/search?reset=1&force=1&status=1&fid=2&pay_later=1&start=20181206&end=20181210"

Membership Tokens

Field Name > > Param in URL

membership_type_id > > type

membership_status_id > > status

start_date > > start & start_high

end_date > > end & end_high

Eg of complete search URL -

"civicrm/member/search?reset=1&force=1&type=1&status=1&start=20181002&start_high=20181004&end=20181103&end_high=20181109"

Participant Tokens

Field Name > > Param in URL

event_id > > event

status_id > > status

role_id > > role

is_pay_later > > pay_later

register_date_from > > register_start

register_date_to > > register_end

Eg of complete search URL -

"civicrm/event/search?reset=1&force=1&event=1&status=2&role=3&pay_later=1&register_start=20181210&register_end=20181214"

Activity Tokens

Field Name Param in URL

activity-type id > > type

activity_status > > status

has a follow-up activity > > hasFollowUp

is a follow-up acivity > > isFollowUp

start date > > dateLow

end date > > dateHigh

Eg of complete search URL -

civicrm/activity/search?reset=1&force=1&status=1&hasFollowUp=1&isFollowUp=1&dateLow=20181210&dateHigh=20181212&type=3

Here is the link to the gitlab ticket https://lab.civicrm.org/dev/core/issues/252

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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