We have Drupal Commons 3 (on Drupal 7). In our groups, I'd like at add a tag near the group's title that links to a certain content types. I have a View ready to go. How might I add that view to an OG tab?

Update and screen shots:

So I have this view: enter image description here

I had hopped to create a new tab here:

enter image description here

By playing with this setting: enter image description here

  • Instead of creating a tag near the group title, you can create a menu item(MENU_LOCAL_TASK) and show the view inside that. Is it ok for you? – inizio Jul 24 '13 at 12:59
  • Yes! How might I do that for the view? I'm happy to post more screen shots of the view if that helps. – Rick Jul 24 '13 at 13:35
  • Means you need to create a menu item using VIEWS or Programmatically ? And screenshot will be helpful.. – inizio Jul 24 '13 at 13:56
  • Preferably, using views to create the menu item. I've added screen shots. – Rick Jul 24 '13 at 16:43
  • To show on the group page you need to use node/%/YOUR_path NOT groups/%/about. I have updated my answer(Programmatically and using VIEWS) you can refer it. – inizio Jul 25 '13 at 7:08

Hope this will help you,

In Drupal 7, you can achieve this using creating a new MENU item via programmatically OR by VIEWS.


  • Create a menu item

    function test_menu() {
      //menu for shows a Content Type related to that group
      $items['node/%/og-content-type'] = array(
      'title' => 'OG content type',
      'page callback' => 'get_og_content_type',
      'page arguments' => array(1),
      'access callback' => 'og_content_type_access',
      'access arguments' => array(1),
      'type' => MENU_LOCAL_TASK,
      'weight' => 5,
      return $items;

  • Now give access to the tab

    function og_content_type_access($etid) {
      if (access) {//check your condition. Based on this condition the TAB will show.
        return TRUE;
      else {
        return FALSE;

  • Now its time to embed your view

    function get_og_content_type($etid) {//Im passing ID in case you want in views.
      $html = '';
      $html = views_embed_view('VIEWNAME', 'display_id', $etid);//embed view
      return $html;

Reference : views_embed_view

Using Views:

  • Just create a new VIEW, with path as node/%/YOUR_PATH, Contextual filters and Permission. Refer the images below

    enter image description here

  • Create a NEW menu TAB now

    enter image description here

  • Add Contextual filters, based on this filter the VIEWS content changes.

    enter image description here

  • Final result

    enter image description here

To create a custom permission in VIEWS, you can use PHP filter.

  • Go to admin > modules and enable PHP filter
  • Go to your VIEW >> Page settings >> Access and select PHP filter and add this code without PHP TAGS.

      if (arg(0) == 'node' && is_numeric(arg(1))) {
        $entity_type = 'node';
        $etid = arg(1);
        if ($group = og_get_group($entity_type, $etid)) {
          return TRUE;
        else {
          return FALSE;

    enter image description here

    enter image description here

    enter image description here


  • You can create you own permission using hook_permission and you can use that permission in VIEWS >> Page settings >> Access
  • Thanks. I may hold this in reserve, but I'd prefer not to use code at the moment. – Rick Jul 24 '13 at 16:42
  • I have updated the answer using views to create the menu item :) – inizio Jul 25 '13 at 7:03
  • A picture is worth a thousand words. Or in this situation an upvote and a marked correct answer. Thanks a million. I appreciate your help on this one. – Rick Jul 25 '13 at 15:05
  • 1
    Only difference is that I changed the context filter to Organic Group ID. – Rick Jul 25 '13 at 15:44
  • I am having this tab now appear on every piece of content. How can I constrain to only Groups (OG)? – Rick Jul 25 '13 at 15:59

I lack the requisite reputation points to comment (really?) but I wanted to call out Richard's remark about using the Group ID in the contextual filter rather than the Node ID.

A group is a node, yes, but I just completed this exercise and it refused to work with Content: NID as the contextual filter. When I changed it to OG Membership: Group ID I began to get the expected view results:

enter image description here

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.