【问题标题】:Using Drupal7 custom entities in views在视图中使用 Drupal7 自定义实体
【发布时间】:2013-01-04 13:33:30
【问题描述】:

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

如何关联这两个实体?

【问题讨论】:

    标签: drupal-7 entity drupal-views


    【解决方案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'),
                     ),
                 );
             }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多