4

I'd like to link a Drupal node (e.g. content type = 'event' with some custom fields in Drupal) to a CiviCRM event via an entity reference field.

The use case is that there are some events that don't require registration, but some that do, but we want them all to show in the same Events list with the same theming options (these will be pulled in various places on the site in various ways, not just in a calendar list). So: we create all the events in Drupal, and for the ones with registration options, we set up a parallel event in CiviCRM which is linked to the Drupal event by the entity reference field I mentioned at the outset, and we would link with a registration button from the Drupal event directly to the CiviCRM event registration page if there was an entity entered.

I've installed CiviCRM Entity and managed to add a field of type 'entity reference' to the Drupal event node.

CiviEvent entity reference field

I can tell it that this is a CiviCRM event, and asked it to sort on the event's start date in descending order, so that new events would be at the top.

Field settings

When trying to edit the field (or create an event node if I just leave the field untouched), I get this:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'civicrm_event.event_start_date' in 'order clause': SELECT civicrm_event.id AS entity_id, :entity_type AS entity_type, NULL AS revision_id, :bundle AS bundle FROM {civicrm_event} civicrm_event ORDER BY civicrm_event.event_start_date DESC; Array ( [:entity_type] => civicrm_event [:bundle] => civicrm_event ) in EntityFieldQuery->execute() (line 1192 of /home/public_html/includes/entity.inc).

It looks like the column name in the database should actually be 'civicrm_event.start_date' -- am I right? I grepped in the civicrm_entity folder and didn't see any references to 'event_start_date' in the code, so where should I look next?

UPDATE: As a temporary fix, if I disable sorting it works as expected.

3
  • Laryn - is the outcome on your drupal node that you have a link eg register that goes to the registration page of civicrm - if so did you do more than set the Field Display to 'link label to entity reference'? I am just getting the event id with no link - should throw in as a new question i guess
    – petednz - fuzion
    Commented Jun 12, 2016 at 3:51
  • @petednz-fuzion We ended up doing a little massaging on this field (eg. in views, and also in the node template) to generate a link/button that goes straight to the register page.
    – Laryn
    Commented Jun 13, 2016 at 2:13
  • k. thanks. on the site we have to do this on they are using a tpl for event content type otherwise i would have done via views too.
    – petednz - fuzion
    Commented Jun 13, 2016 at 5:40

1 Answer 1

1

When you install Entityreference, you get a Views Display, 'Entityreference'

You can create a Entityreference view, and use that View to choose what the options are for your entityreference field widget.

In this view you can sort, and get your sort order that way.

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.