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 (Moderator: Donald Lobo) »
  • Displaying custom search results after selecting an option in the contact search
Pages: [1]

Author Topic: Displaying custom search results after selecting an option in the contact search  (Read 1649 times)

axlroach

  • I’m new here
  • *
  • Posts: 22
  • Karma: 0
Displaying custom search results after selecting an option in the contact search
February 08, 2009, 06:55:22 pm
Hi all,

I'm trying to add an action to the contact search dropdown.  I have 2 groups - Legislators and Constituents, and I need my users to be able to display a screen of all constituents of one or more legislators.

Here is the basic use case:
1. The user runs a search on the Legislators group. 
2. A number of Legislator contact records are returned and displayed along with form elements for action task select and submit, paging controls, a checkbox to select each result row and view/edit actions.
3. The user selects one or more of the contacts by checking the checkbox for their record(s).
4. Now the user chooses the newly added contact search dropdown action, 'Show Constituents'.
5. The user now sees a screen (a quick form) that says 'Show all contacts in the Constituent group where Senate District = xxx, xxx, xxx?' (where 'xxx' are the senate district(s) represented by the contact(s) selected from the Legislators group search results).
6. The user clicks the confirmation button.
7. A number of Constituent records are returned and displayed along with form elements for action task select and submit, paging controls, a checkbox to select each result row and view/edit actions.


I've followed the instructions at: http://wiki.civicrm.org/confluence/display/CRMDOC/How+to+Add+Actions+to+the+Contact+Search+Dropdown, and that has gotten me down to step 7 in the above use case.  Basically, after the user clicks the confirmation button in step 6, I query the database in the postProcess() method to get the contacts that live in the appropriate senate district(s).  I then loop through the results putting each result row in an array called '$rows'.  Then I do $this->assign('rows', $rows);

I know the data in this array is correct because I've print_r'd it, but what I can't figure out is how and where to pass this data off in order to render it into a list with form elements for action task select and submit, paging controls, a checkbox to select each row and view/edit actions.  In short to display it like normal custom search output.

If anyone could help point me in the right direction I would sincerely appreciate it.


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Displaying custom search results after selecting an option in the contact search
February 09, 2009, 07:39:51 am

the easiest option for you to accomplish 7 in 2.1 is probably:

a. create a custom search that returns all constituents in senate districts. Ensure the custom search can take in arguments via the URL (check Sample.php for an example)

b. For your step 7 below, the postProcess should redirect to the above custom search sending in the senate districts as  GET parameter

Not the most elegant, but should work :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

axlroach

  • I’m new here
  • *
  • Posts: 22
  • Karma: 0
Re: Displaying custom search results after selecting an option in the contact se
February 09, 2009, 12:33:25 pm
Hi lobo,
Firstly, thanks for your fast response.  That does seem like it would work.  However, the problem with this solution would be that the user would need to confirm twice.  The user will confirm from the buildQuickForm() method in the GetConstituents class, and then will be presented with a 'Search' button when redirected to the custom search screen.  Is there a way to bypass the 'Search' confirmation and just go straight to the custom search's results?

Thanks,
axlroach

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Displaying custom search results after selecting an option in the contact search
February 09, 2009, 04:28:02 pm

axlroach:

append a "force=1" at the end of the url

so:

http://sandbox.civicrm.org/civicrm/contact/search/custom?csid=1&reset=1&force=1

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Displaying custom search results after selecting an option in the contact search

This forum was archived on 2017-11-26.