2

Apologies if this question has already been answered. I'm developing an emergency notification site using Drupal 7 and Organic Groups and currently it's building-driven -- i.e., the buildings are the groups which have users connected to them. They can add notes, photos, etc. and all works well.

Now it seems that it would be better to have an event-driven system. Admins could create an event (such as a hurricane) and then assign those buildings that are in the path of the event. I've tried creating a new Event content type and using the Entity Reference module, linking the Building list to the Event. However, when it comes time to create a View to display the information I'm running into the following error message when I build the view relationship using Entity Reference: Referenced Entity: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'og_membership.field_affected_buildings_target_id' in 'on clause'

Here is my exported view (note that it doesn't have any fields yet but it does have the broken relationship):

$view = new view();
$view->name = 'event_list';
$view->description = 'Displays all emergency events with affected buildings.';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Event List Test';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Events';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['pager']['options']['items_per_page'] = '10';
$handler->display->display_options['style_plugin'] = 'table';
$handler->display->display_options['style_options']['grouping'] = array(
  0 => array(
    'field' => 'title',
    'rendered' => 1,
    'rendered_strip' => 0,
  ),
);
$handler->display->display_options['style_options']['columns'] = array(
  'title' => 'title',
  'field_address' => 'field_address',
);
$handler->display->display_options['style_options']['default'] = '-1';
$handler->display->display_options['style_options']['info'] = array(
  'title' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
  'field_address' => array(
    'sortable' => 0,
    'default_sort_order' => 'asc',
    'align' => '',
    'separator' => '',
    'empty_column' => 0,
  ),
);
/* Relationship: Entity Reference: Referenced Entity */
$handler->display->display_options['relationships']['field_affected_buildings_target_id']['id'] = 'field_affected_buildings_target_id';
$handler->display->display_options['relationships']['field_affected_buildings_target_id']['table'] = 'og_membership';
$handler->display->display_options['relationships']['field_affected_buildings_target_id']['field'] = 'field_affected_buildings_target_id';
$handler->display->display_options['relationships']['field_affected_buildings_target_id']['label'] = 'Building';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'event' => 'event',
);

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['path'] = 'events';

Thanks to anyone who can point me in the right direction!

0

I had the same case.

I removed the entity reference (which cause the problem) from Relationships and added necessary fields with Rendered Entity Formatter.

You can choose any view mode you want and show all the required data. No Relationships are required.

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.