2013-01-04 33 views
2

我已经在drupal 7中使用hook_entity_info创建了两个自定义实体。为给定数据库表创建实体。 我能够分别为每个实体创建一个视图。但是想要一起创建两个实体的视图。视图中的“关系”选项显示“没有可用的关系”。并且添加字段选项仅显示secleted实体的字段。在视图中使用Drupal7自定义实体

我如何关联两个实体?

回答

1

我能够配有两个解决方案:

1)使用关系,关系结束字段,UI关系

2)使用来自商务模块hook_views_data_alter例如:

  Function hook_views_data_alter(){ 
      // Expose the uid as a relationship to users. 
      $data['users']['uc_orders'] = array(
       'title' => t('Orders'), 
       'help' => t('Relate a user to the orders they have placed. This relationship will create one record for each order placed by the user.'), 
       'relationship' => array(
        'base' => 'uc_orders', 
        'base field' => 'uid', 
        'relationship field' => 'uid', 
        'handler' => 'views_handler_relationship', 
        'label' => t('orders'), 
       ), 
      ); 
     } 
相关问题