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) »
  • Using events as a custom search parameter in 2.0.1
Pages: [1]

Author Topic: Using events as a custom search parameter in 2.0.1  (Read 2132 times)

GloryFish

  • Guest
Using events as a custom search parameter in 2.0.1
April 10, 2008, 09:05:57 am
I am building a custom search which will allow a user to select an upcoming event. Based on the event the search will return all attendees of that event. I am having trouble finding the right code to generate a list box containing upcoming events that can be used to perform a custom search.

Any suggestions or examples would be extremely helpful. Thank you.

Using CiviCRM 2.0.1

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: Using events as a custom search parameter in 2.0.1
April 10, 2008, 11:34:59 am

Isn't the below handled by the default event search?

You can figure out how to construct a select element by looking at the code in CRM/Contact/Form/Search/Custom/*.php. ActivitySearch.php uses the select element (so does Sample.php and a few other files)

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

GloryFish

  • Guest
Re: Using events as a custom search parameter in 2.0.1
April 10, 2008, 12:00:51 pm
The end user in this case is the site administrator. This person would like to select an upcoming event and export a list of all attendees including their contact information, employer, and some custom data. I am attempting this with a Custom Search because the employer relationship cannot currently be exported along with the other data via an event search.

I am working through the various examples in CRM/Contact/Form/Search/Custom/*.php and I can create a select element and populate it with some default data but I'm unsure of the best way to populate it with a list of events. Should that come from a query or is there a core function that can retrieve that data? This is only my second day with the API so I'm still getting a handle on where everything is and the best way to carry out certain functions.

Thank you very much for your help.

GloryFish

  • Guest
Re: Using events as a custom search parameter in 2.0.1
April 10, 2008, 01:25:31 pm
I was able to produce the event select element I needed with the following code:

Code: [Select]
require_once 'CRM/Event/PseudoConstant.php';
 $events = array('' => ts('- Choose an event -')) + CRM_Event_PseudoConstant::event( );
 $form->addElement('select', 'event', ts('Event'), $events);


I had suspected that there was something like CRM_Event_PseudoConstant::event( ) but I wasn't sue until I started grepping through the source. That did the trick and it's working nicely.

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Using events as a custom search parameter in 2.0.1
May 16, 2008, 02:09:59 pm
we also need this.  will try and see if it helps.  thanks!

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: Using events as a custom search parameter in 2.0.1
May 16, 2008, 07:06:10 pm

gloryfish:

if you added a custom search component to list / export all attendees of an event, can you please post your search file here, so other folks can make use of your work :)

thanx

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) »
  • Using events as a custom search parameter in 2.0.1

This forum was archived on 2017-11-26.