2013-01-04 32 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'), 
       ), 
      ); 
     } 
相關問題