0

I have used Organic Groups 7.x-2.7 to create groups and can create content which is allocated only to that group. When I am viewing a group content node how do I create a link back up to the parent group? Ideally I'd like to be able to create a views block with this link in it.

  • Could you please try solution, that described here? – Andrew Jun 22 '15 at 15:45
  • Sure. I will give it a go and report back – Paul Trotter Jun 22 '15 at 15:46
  • I tried that post (which suggests a method for add the title of the group). I didn't however have any luck getting it to work. It seems like some of the options have changed with Organic Groups 7x-2. I tried to use the suggestions in the comments but still couldn't get this to work – Paul Trotter Jun 22 '15 at 16:20
  • How are you showing your node? In a normal node view you can just display the parent content in the content type display so I'm assuming that you want to set this up in a view, are you using panels or just plain views and blocks? – burnsjeremy Jun 22 '15 at 22:32
  • @burnsjeremy Yes I can get the link to the parent item in the content. So I'll try passing this to the view using contextual filters. – Paul Trotter Jun 23 '15 at 11:05
0

In terms of OG Groups I usually have a bigger issue getting what I want on the screen without Panels but for OP's question the answer is pretty easy. So of course there are a couple of ways to complete this but OP wanted a view block with a link to the group to show on group content. So without further ado here is the how to for this.

  • First create a new view with a block of unformatted list of content titles.
  • Then add a Contextual filters Content: Nid.
  • Set that filter to Current OG Group from context (Please make sure that you have OG Context turned on or this will not work).
  • Save the view.
  • Set the block and navigate to a group content page, you should see the block.

I am adding some screenshots just incase anyone needs some visuals, there aren't many but if anyone needs some more visuals just let me know (and Yes I know I need to upgrade to 7.38).

Image of Contextual Filter Screen

Create Block View, unformatted list of content links

Basic view export

This does not have any filtering or anything to make it not show on the actual group screen or anything like that. So you will have to add those things yourself. This is just the basic link back to the group from group content. However, it will not show on node content that is not part of a group at all. So you could technically use block settings to make it show only on the node types that you want.

$view = new view();
$view->name = 'og_block_link';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'OG Block Link';
$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'] = 'OG Block Link';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$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'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '5';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Post date */
$handler->display->display_options['sorts']['created']['id'] = 'created';
$handler->display->display_options['sorts']['created']['table'] = 'node';
$handler->display->display_options['sorts']['created']['field'] = 'created';
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'og_context';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

/* Display: Block */
$handler = $view->new_display('block', 'Block', 'block');

Please let me know if you have any issues with this and I will be happy to add/edit my answer with more information, thanks!

0

burnsjeremy was right that the information I need is available to my node itself. To get this into a views block to position in a different place etc I can use contextual filter on 'Content: Nid' and 'When the filter value is NOT available' set the 'default value' to 'Content ID From URL'. I can then add the fields as normal via views.

Next will be the challenge of getting the parent group of a child group when on the node of a piece of content within the child group.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.