Reputation: 143
I have a site that is running on drupal 7 and uses civicrm 4.4.1. I need the events to be included in the search results.
So far all I have found was dated documentation on civicrm that required modules that are not available for Drupal 7.
I also tried the search page module and it is not grabbing the events.
Upvotes: 1
Views: 86
Reputation: 818
We create content in Drupal and link it to Civi event pages using a Computed Field that matches Event Name to the node's Title field, and Event Start Date to the node's Event Date field. Sample code for the Computed Field:
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
$query = "SELECT
ce.id
FROM {node} n
INNER JOIN {field_data_field_event_date} de ON n.nid = de.entity_id AND n.vid = de.revision_id
INNER JOIN {civicrm_event} ce ON n.title = ce.title COLLATE utf8_unicode_ci
AND ce.start_date = convert_tz(field_event_date_value,'GMT','America/New_York')
WHERE n.nid = :nid
AND n.vid = :vid
LIMIT 1";
$result = db_query($query,
array(':vid' => $vid, ':nid' => $id))->fetchField(0);
if ($result === NULL || $result == "")
{
$entity_field[0]['value'] = 0;
}
else
{
$entity_field[0]['value'] = $result;
}
Then you can use a bit of display code like this:
if ($entity_field_item['value'] == 0)
{
$display_output = '';
}
else
{
$display_output = '<a href="https://examplesite.org/civicrm/event/register?reset=1&id=' . $entity_field_item['value'] . '">Buy tickets</a>';
}
Since we have the Civi event code saved to the node, we can also use any native Drupal search or Views functionality, and get creative in Drupal templates as needed. Other options could be to write your own module that does something like this, or consider using the Civi REST endpoint /sites/all/modules/civicrm/extern/rest.php?entity=Event&action=getlist&json={"sequential":1}&api_key=yoursitekey&key=yourkey
with Drupal Feeds and Feeds Extensible Parsers modules for a solution that creates and updates the Drupal events with minimal code required.
Upvotes: 0
Reputation: 776
I haven't seen anything pre-built that will include CiviCRM events in the standard Drupal site search. Looking at the search api, I think it is possible to create a module to do that, but I don't think it is trivial. I haven't written any modules for the search api, but it seems like there is a bit of bookkeeping to be done to write this kind of integration.
I've handled this in a couple of ways for my customers. One, create a content type for Events and put a detailed description and basic date information in the content type. When creating events in CiviCRM, just make a barebones event for registration and link to the event registration page directly from the event node. Two, make event search a separate action, with a nice link and a view.
I know that neither of these solutions is ideal, but I don't see a quick solution apart from writing your own search plugin.
Upvotes: 0
Reputation: 705
It's a little unclear what you're looking for, so I'll answer two ways.
You can search for event participants most easily by going into the Search menu and selecting Advanced Search. You can see the events information by clicking on the Events header--the section will open up. You don't need to enter anything else on the search form unless you want to search for that too (i.e. fundraiser attendees who live in West Virginia).
If you want CiviCRM events to show up in your Drupal content search results, you'll need to get the events to appear as content. CiviCRM information is 100% separate from Drupal content, but you may have some luck using the CiviCRM Entity module https://drupal.org/project/civicrm_entity to expose CiviCRM events as entities.
Upvotes: 0