Hi Everyone,
I am using Group 8.x-1.0-rc2 with Drupal 8.7.1 and it works great apart from one issue with creating a view to display on a node which is a member of a group which in turn displays other nodes that are also members of the same group.
Now I can create a view which is of 'Group Content' which when viewing the group displays other nodes from that group, but when you click to view a node the view is no longer displayed as there is no reference on the node page to which group it is a member of. I have also created a view of 'Content' as outlined in the numerous guides here on the Drupal Group page and incidents list but have the same issue.
I have tried all of the following guides but some seem to use relationships and filters which I dont seem to have available:
https://www.optasy.com/blog/drupal-8-group-module-how-list-related-group...
https://www.drupal.org/project/group/issues/2689663
https://www.drupal.org/node/2693847
https://www.drupal.org/node/2710795
Do I need to add something to the node which has the group relationship so that the view can reference it?
I'm really hoping someone is able to point out where I am going wrong as I'm really stuck at this point. The main, if not only reason I need to create this view is when you view a node from the link on the group page the user does not see any reference to the group that the node is a member of.
These below are the 2 views I have so far which are displaying related group content as blocks but disappear when you view the node
View of Node Content
uuid: 70549093-1c0c-410c-a655-6dd3e44de763
langcode: en
status: true
dependencies:
module:
- group
- node
- user
id: test_content_content
label: 'Test Content Content'
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: some
options:
items_per_page: 50
offset: 0
style:
type: default
row:
type: fields
fields:
title:
id: title
table: node_field_data
field: title
entity_type: node
entity_field: title
label: ''
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
settings:
link_to_entity: true
plugin_id: field
relationship: none
group_type: group
admin_label: ''
exclude: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_alter_empty: true
click_sort_column: value
type: string
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
gid:
id: gid
table: group_content_field_data
field: gid
relationship: group_content
group_type: group
admin_label: ''
label: 'Parent Group'
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: entity_reference_label
settings:
link: true
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: group_content
entity_field: gid
plugin_id: field
filters:
status:
value: '1'
table: node_field_data
field: status
plugin_id: boolean
entity_type: node
entity_field: status
id: status
expose:
operator: ''
group: 1
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
entity_type: node
entity_field: created
plugin_id: date
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
granularity: second
title: 'Test Content Content'
header: { }
footer: { }
empty: { }
relationships:
group_content:
id: group_content
table: node_field_data
field: group_content
relationship: none
group_type: group
admin_label: 'Content group content'
required: true
group_content_plugins:
'group_node:minor_incident': '0'
'group_node:safeguarding_incident': '0'
'group_node:serious_incident': '0'
entity_type: node
plugin_id: group_content_to_entity_reverse
gid:
id: gid
table: group_content_field_data
field: gid
relationship: group_content
group_type: group
admin_label: Group
required: true
entity_type: group_content
entity_field: gid
plugin_id: standard
arguments:
gid:
id: gid
table: group_content_field_data
field: gid
relationship: group_content
group_type: group
admin_label: ''
default_action: default
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: group_id_from_url
default_argument_options: { }
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
break_phrase: false
not: false
entity_type: group_content
entity_field: gid
plugin_id: group_id
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- route
- url
- 'user.node_grants:view'
- user.permissions
tags: { }
block_1:
display_plugin: block
id: block_1
display_title: Block
position: 1
display_options:
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- route
- url
- 'user.node_grants:view'
- user.permissions
tags: { }
View of Group Content
uuid: 79c0711f-fe6e-4c96-9692-d77446e37a3e
langcode: en
status: true
dependencies:
config:
- group.content_type.group_content_type_622783567a7ca
- group.content_type.group_content_type_ba09dbd234bc3
- group.content_type.pupil-group_node-minor_incident
module:
- group
id: test_group_content
label: 'Test Group Content'
module: views
description: ''
tag: ''
base_table: group_content_field_data
base_field: id
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: none
options: { }
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: some
options:
items_per_page: 50
offset: 0
style:
type: default
row:
type: fields
fields:
gid:
id: gid
table: group_content_field_data
field: gid
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: target_id
type: entity_reference_label
settings:
link: true
group_column: target_id
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: group_content
entity_field: gid
plugin_id: field
label:
id: label
table: group_content_field_data
field: label
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: true
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
entity_type: null
entity_field: label
plugin_id: field
filters:
type_1:
id: type_1
table: group_content_field_data
field: type
relationship: none
group_type: group
admin_label: ''
operator: in
value:
pupil-group_node-minor_incident: pupil-group_node-minor_incident
group_content_type_ba09dbd234bc3: group_content_type_ba09dbd234bc3
group_content_type_622783567a7ca: group_content_type_622783567a7ca
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
entity_type: group_content
entity_field: type
plugin_id: bundle
sorts: { }
title: 'Test Group Content'
header: { }
footer: { }
empty: { }
relationships:
gid:
id: gid
table: group_content_field_data
field: gid
relationship: none
group_type: group
admin_label: Group
required: true
entity_type: group_content
entity_field: gid
plugin_id: standard
arguments:
id:
id: id
table: groups_field_data
field: id
relationship: gid
group_type: group
admin_label: ''
default_action: default
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: group_id_from_url
default_argument_options: { }
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
break_phrase: false
not: false
entity_type: group
entity_field: id
plugin_id: group_id
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- route
- url
tags: { }
block_1:
display_plugin: block
id: block_1
display_title: Block
position: 1
display_options:
display_extenders: { }
cache_metadata:
max-age: -1
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- route
- url
tags: { }
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | group_limitation_relationships.jpg | 22.18 KB | wolffereast |
Issue fork group-3064949
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
SergeBr commentedHello,
I know it is a little bit late but I was still having this problem :-)
I found this post and I tested it, it works :
It shows, with Views, Group Informations on the page of a node belonging to a group.
https://www.optasy.com/blog/drupal-8-group-module-how-list-related-group...
Comment #3
jcmartinezAs of this time, it doesn't appear to be a clear way of doing this i.e creating a view of content that's related by parent group to the current node.
The article at Optasy, referenced by #2, is one of the links provided at the top of this question. In that article there is a comment of a user indicating that "Parent group" can't be found. It doesn't work.
If anyone could share better instructions, it will be appreciated.
Comment #4
thomasmurphy commentedSo you want to see nodes which are members of the same group? This is done by
1.Making a view of nodes of the content type required
2.Adding a relationship to the group content (the relationship entity) that represents the group
3. Adding a relationship from the group content to the parent group
It's helpful at this stage to have a table of results with the columns
1.node ID
2.group content ID (the relationship ID)
3.group ID
Now you want to see all the other nodes which are part of each group, so add another relationship to group content for the group, ie all relationships. Then add a relationship from the group content to the node. You can make extend the table at this stage to see what's going on
1.node ID (original)
2.group content ID (the relationship ID)
3.group ID
4.group content ID (each of the members / relationships of each group from row 3)
5. node ID (the node IDs of each of the members of each group)
This will give you a lot of results as the tree expands as we go from column 1>5. You'll need to reduce the number of results by limiting it by the first node ID. So add a node ID contextual filter to the view, and use a default of node ID from current URL. Once you've got the relationship working just strip out the table and put in something more useful.
One of the most confusing things about groups is that the relationships are called group content, whereas most people think that this is actual content in the group. Poorly named, in my opinion, but it makes more sense if you think of it as a group relationship. The same object is used for users being members.
Comment #5
sagannotcarl commentedWow @thomasmurphy you saved my day thank you. This was complicated but I just followed your steps slowly and it worked!
Comment #6
mrpauldriver commentedEven with the detailed information from @thomasmurphy this is still super complicated. Yes the language and naming is a problem.
Could anyone post a config export?
Comment #7
wolffereast commented@thomasmurphy 's post got us there but the naming is a hurdle so I wanted to share my notes and a screenshot to hopefully help the next person to find this solution.
The end result will be four relationships and a contextual filter, see the attached screenshot.
Relationships
Contextual Filters
Edit: Current versions
core: 9.4.8
group: 3.0.0-beta6
Comment #9
freelockThis is substantially easier with the Group Purl module. The 3.x-dev version supports Group 3 now, and is just waiting for a compatible version of the PURL module to get released so the tests pass.
With Group PURL active, you configure pathauto for your groups, and set content types that go in groups to "keep context." And then you have a Views contextual filter default argument for the active group ("Group ID from Purl"). No need to muck about with relationships -- if a block is placed on a page in a particular group, this will set the default argument for you.