web-dev-qa-db-ja.com

ビューを使用してメンバーのオーガニックグループをリストする(7.x-2.3)

サイトをOG 7.x-1.4からOG 7.x-2.3に移行しています。移行はうまくいったようですが、現在のユーザーグループ(つまり、ユーザーがメンバーになっているグループ)を表示するビューを壊しました。 1.4の元のビューでは、コンテキストフィルターがありました。

  • (OGグループのOGメンバーシップ)「エンティティID」にユーザーIDを渡します。

そして次の関係:

  • OGグループ:ノードのOGグループ
  • (ノードはOGグループです)OGグループ:OGグループのOGメンバーシップ

ただし、新しいOrganic Groups 7.x-2.3はOGMembershipデータモデルを使用するようになり、OGMembershipを使用してこのビューを再作成する方法を理解できません。正確に動作する方法が明確ではないため、詳細なドキュメントを見つけることができないようです。この種のもののために。

4
VirtualMitra

これは、最初にOGメンバーシップIDを取得する方法です。

新しいビューを追加します。表示-> OGメンバーシップ(重要!)次に、一部の表示にコンテキストフィルターを追加します-> OGメンバーシップ:エンティティID。デフォルト値を入力->タイプ->ログインしたユーザーのユーザーID。タイトルを上書き:%1のグループ。検証基準を指定->ユーザー。

これで、IDのリストができました。

次に、グループの実際のタイトルを取得するには(ベーステーブルはノードではなくOGメンバーシップであるため)、関係を追加します->グループNode。フィールドを追加します->コンテンツ:タイトル。関係-> OGメンバーシップのグループノード。

今あなたもタイトルを持っています。いくつかのフィルターを追加し、好みに合わせて基準を並べ替えます。

11

上記のKariKääriäinenで説明されているように、このビューを実行するビューのエクスポートを次に示します。

$view = new view();
$view->name = 'my_groups';
$view->description = 'List of Groups I\'m Subscribed To';
$view->tag = 'default';
$view->base_table = 'og_membership';
$view->human_name = 'My Groups';
$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'] = 'My Groups';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'role';
$handler->display->display_options['access']['role'] = array(
  2 => '2',
);
$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'] = '200';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'table';
/* Field: OG membership: Delete link */
$handler->display->display_options['fields']['delete_membership']['id'] = 'delete_membership';
$handler->display->display_options['fields']['delete_membership']['table'] = 'og_membership';
$handler->display->display_options['fields']['delete_membership']['field'] = 'delete_membership';
$handler->display->display_options['fields']['delete_membership']['label'] = 'Remove';
/* Field: OG membership: Edit link */
$handler->display->display_options['fields']['edit_membership']['id'] = 'edit_membership';
$handler->display->display_options['fields']['edit_membership']['table'] = 'og_membership';
$handler->display->display_options['fields']['edit_membership']['field'] = 'edit_membership';
$handler->display->display_options['fields']['edit_membership']['label'] = 'Edit';
/* Field: OG membership: Rendered OG membership */
$handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_og_membership';
$handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
$handler->display->display_options['fields']['rendered_entity']['bypass_access'] = 0;
/* Contextual filter: OG membership: Entity id */
$handler->display->display_options['arguments']['etid']['id'] = 'etid';
$handler->display->display_options['arguments']['etid']['table'] = 'og_membership';
$handler->display->display_options['arguments']['etid']['field'] = 'etid';
$handler->display->display_options['arguments']['etid']['default_action'] = 'default';
$handler->display->display_options['arguments']['etid']['default_argument_type'] = 'current_user';
$handler->display->display_options['arguments']['etid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['etid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['etid']['summary_options']['items_per_page'] = '25';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'my_groups';
$handler->display->display_options['menu']['type'] = 'tab';
$handler->display->display_options['menu']['title'] = 'My Groups';
$handler->display->display_options['menu']['description'] = 'Groups that I am subscribed to';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['menu']['context_only_inline'] = 0;
$translatables['my_groups'] = array(
  t('Master'),
  t('My Groups'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('« first'),
  t('‹ previous'),
  t('next ›'),
  t('last »'),
  t('Remove'),
  t('Edit'),
  t('Rendered OG membership'),
  t('All'),
  t('Page'),
);

$view = new view();
$view->name = 'my_groups';
$view->description = 'List of Groups I\'m Subscribed To';
$view->tag = 'default';
$view->base_table = 'og_membership';
$view->human_name = 'My Groups';
$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'] = 'My Groups';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'role';
$handler->display->display_options['access']['role'] = array(
  2 => '2',
);
$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'] = '200';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['pager']['options']['id'] = '0';
$handler->display->display_options['pager']['options']['quantity'] = '9';
$handler->display->display_options['style_plugin'] = 'table';
/* Field: OG membership: Delete link */
$handler->display->display_options['fields']['delete_membership']['id'] = 'delete_membership';
$handler->display->display_options['fields']['delete_membership']['table'] = 'og_membership';
$handler->display->display_options['fields']['delete_membership']['field'] = 'delete_membership';
$handler->display->display_options['fields']['delete_membership']['label'] = 'Remove';
/* Field: OG membership: Edit link */
$handler->display->display_options['fields']['edit_membership']['id'] = 'edit_membership';
$handler->display->display_options['fields']['edit_membership']['table'] = 'og_membership';
$handler->display->display_options['fields']['edit_membership']['field'] = 'edit_membership';
$handler->display->display_options['fields']['edit_membership']['label'] = 'Edit';
/* Field: OG membership: Rendered OG membership */
$handler->display->display_options['fields']['rendered_entity']['id'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['table'] = 'views_entity_og_membership';
$handler->display->display_options['fields']['rendered_entity']['field'] = 'rendered_entity';
$handler->display->display_options['fields']['rendered_entity']['link_to_entity'] = 1;
$handler->display->display_options['fields']['rendered_entity']['bypass_access'] = 0;
/* Contextual filter: OG membership: Entity id */
$handler->display->display_options['arguments']['etid']['id'] = 'etid';
$handler->display->display_options['arguments']['etid']['table'] = 'og_membership';
$handler->display->display_options['arguments']['etid']['field'] = 'etid';
$handler->display->display_options['arguments']['etid']['default_action'] = 'default';
$handler->display->display_options['arguments']['etid']['default_argument_type'] = 'current_user';
$handler->display->display_options['arguments']['etid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['etid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['etid']['summary_options']['items_per_page'] = '25';

/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page');
$handler->display->display_options['path'] = 'my_groups';
$handler->display->display_options['menu']['type'] = 'tab';
$handler->display->display_options['menu']['title'] = 'My Groups';
$handler->display->display_options['menu']['description'] = 'Groups that I am subscribed to';
$handler->display->display_options['menu']['weight'] = '0';
$handler->display->display_options['menu']['context'] = 0;
$handler->display->display_options['menu']['context_only_inline'] = 0;
$translatables['my_groups'] = array(
  t('Master'),
  t('My Groups'),
  t('more'),
  t('Apply'),
  t('Reset'),
  t('Sort by'),
  t('Asc'),
  t('Desc'),
  t('Items per page'),
  t('- All -'),
  t('Offset'),
  t('« first'),
  t('‹ previous'),
  t('next ›'),
  t('last »'),
  t('Remove'),
  t('Edit'),
  t('Rendered OG membership'),
  t('All'),
  t('Page'),
);
0
Darrell Duane