Configuring the OG Group Homepage and Tabs

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
briwood's picture

My goal is to create a simple group with a default homepage tab.

My problem is that an anonymous user sees the following tabs when they click on the group:

View, Home, Events, Officers

I have figured out how to make Home the default tab, but I can't make the view tab disappear for anonymous user. When the anonymous user clicks on the group title from the groups directory I would like them to see the tabs:

Home (selected), Events, Officers

(I'm not clear on the reason that the View tab exists, but I think that it is always supposed to show up for og administrators.)

I'd also like just one row of tabs i.e. I don't want "View, Home, Events, Officers" to be subtabs of a tab like GroupName. This seems to be controlled by the menu settings in the View Config (step 1 below). My reason for wanting this is that I hope to be able to clone a simple group site as Jessie describes here: http://groups.drupal.org/node/13337#comment-43300

Here is how I've set things up in Drupal 5. A few questions are embedded in the outline:

1. Created view:  og_ghp_filter_list.
    i. View Config
        1) Provide page view: checked
        2) URL: node/$group/home
            a) (at 1st I wasn't using /home on the end.  I think I need something there, though…)
        3) Provide Menu: checked
            a) <i><strong>Question:</strong> Does this mean that the group should magically show up somewhere in the Navigation menu? (It does not for me, but I might have deleted it from admin/build/menu when I was working on something else.)</i>
        4) Menu as Tab: checked
        5) Make Default Menu Tab: checked
        6) Parent Menu Item Type: Already exists
            a) (don’t really understand this…yet)
        7) Arguments: Group NID is first argument
2. Admin/og/og 
    i. Homepage Presentation set to og_ghp_filter_list
3. admin/panels/views
    i. og_ghp_filter_list added to "Organic groups" category
    ii. View Type = embedded
    iii. Argument: OG: Group nid(s)
        1) Argument source = from panel
        2) Required contex = Group
        3) (everything else at defaults)
4. admin/panels/panel-page
    i. Settings
        1) Panel name = organization_homepage
        2) Panel title = Org Hp
        3) Path= node/%
    ii. Advanced
        1) (Left these settings at defaults)
            a) <i><strong>Question:</strong> How do the menu settings here interact with the menu settings in the view?</i>
    iii. Context
        1) Arguments
            a) NodeID
                i) (I have "Own Display" set for some other group node types - shouldn't matter…)
    iv. Content
        1) (subtab) Node ID: Organization (it's  a subtab because: 4.iii.1.a.i)
            a) Og_ghp_filter_list  
            (URL: admin/panels/panel-page/organization_homepage/edit/content/argument_0-organization)
                i) Override title = unchecked
5. Groups > Group1 > Pages (node/93/og_panels)
    i. "Home" page created  
        1) Homepage radio button selected
        2) Edit Page (link)
            a) Page Title = Home
            b) Published = checked
        3) Edit Content (link) (node/93/og_panels/10/panel_content?destination=node%2F93%2Fog_panels)
            a) Og_ghp_filter_list 
            (URL: node/93/og_panels/10/panel_content?destination=node%2F93%2Fog_panels)
                i) <i><strong>Question:</strong> How do these settings interact with the admin/panels/panel-page (4.iv.1)</i>


I have a feeling that some of what I'm doing is redundant...

Comments

RE: OG GHP & Tabs

jkeck's picture

This issue has been a pain for me too. I have asked several people on G.D.O. and pretty much got blown off everytime. My solution was to override the View menu option for Groups in my Template.php file in my theme(PHP saying IF Node-type == 'my group type' && Menu Item == 'View' - THEN menu title == 'Home'). It's a really hacky workaround, but it works none the less.

Answers to your questions below:

  1. Created view: og_ghp_filter_list.
    i. View Config
    1) Provide page view: checked
    2) URL: node/$group/home
    a) (at 1st I wasn't using /home on the end. I think I need something there, though…)
    You don't need anything at the end of the url. I'm using just node/% and the url for my groups are www.mysite.com/drupal/group-name
    3) Provide Menu: checked
    a) Question: Does this mean that the group should magically show up somewhere in the Navigation menu? (It does not for me, but I might have deleted it from admin/build/menu when I was working on something else.)
    This means you can set this group to be somewhere as a link in a menu. The typical thing done here is to make it as a menu item under Groups in the Navigation Menu (I just create a block to display the groups as a list and do not use the nav menu)
    4) Menu as Tab: checked
    5) Make Default Menu Tab: checked
    6) Parent Menu Item Type: Already exists
    a) (don’t really understand this…yet)
    I don't set any menu options in the view, I'm pretty sure these menu options are useless once using OG Panels Pages
    7) Arguments: Group NID is first argument
  2. Admin/og/og
    i. Homepage Presentation set to og_ghp_filter_list
  3. admin/panels/views
    i. og_ghp_filter_list added to "Organic groups" category
    ii. View Type = embedded
    iii. Argument: OG: Group nid(s)
    1) Argument source = from panel
    2) Required contex = Group
    3) (everything else at defaults)
  4. admin/panels/panel-page
    i. Settings
    1) Panel name = organization_homepage
    2) Panel title = Org Hp
    3) Path= node/%
    ii. Advanced
    1) (Left these settings at defaults)
    a) Question: How do the menu settings here interact with the menu settings in the view?
    I don't really understand these settings myself. I have tried about every option possible and nothing seems usable
    iii. Context
    1) Arguments
    a) NodeID
    i) (I have "Own Display" set for some other group node types - shouldn't matter…)
    Every group node type that is tagged w/ Own Layout. Everybody else will get the default layout
    iv. Content
    1) (subtab) Node ID: Organization (it's a subtab because: 4.iii.1.a.i)
    a) Og_ghp_filter_list
    (URL: admin/panels/panel-page/organization_homepage/edit/content/argument_0-organization)
    i) Override title = unchecked
  5. Groups > Group1 > Pages (node/93/og_panels)
    i. "Home" page created
    1) Homepage radio button selected
    You should not have any of your subpages selected as the homepage. Your default homepage is already set by the panels page
    2) Edit Page (link)
    a) Page Title = Home
    b) Published = checked
    3) Edit Content (link) (node/93/og_panels/10/panel_content?destination=node%2F93%2Fog_panels)
    a) Og_ghp_filter_list
    (URL: node/93/og_panels/10/panel_content?destination=node%2F93%2Fog_panels)
    i) Question: How do these settings interact with the admin/panels/panel-page (4.iv.1)
    I don't quite understand your last question

I have a feeling that some of what I'm doing is redundant...

Thanks for replying!

briwood's picture

Jessie,

Thanks again for the help. I really appreciate you reading through the long outline.

I may not have time to work on this until Monday, but I'll try to update the group on my progress.

1) Homepage radio button selected

You should not have any of your subpages selected as the homepage. Your default homepage is already set by the panels page

That's what I suspected.

My solution was to override the View menu option for Groups in my Template.php file in my theme(PHP saying IF Node-type == 'my group type' && Menu Item == 'View' - THEN menu title == 'Home'). It's a really hacky workaround, but it works none the less.

I will probably use your approach. The reason I was thinking that I needed to also create a Home page in Groups > (Group Name) > Pages is that in this Dojo video http://groups.drupal.org/node/10235 JoshK has both a Home tab and a View tab on his OG admin page (I'll have to watch it again carefully). (I'm now realizing that maybe I should ask some questions in that discussion.)

Can you provide the code snippet?

kmillecam-gdo's picture

Hi guys,

I'm running into the same issue.

Could you kindly provide the code snippet you're using in your template.php file?

Thanks,
Kevin

I have the same problem

raska__'s picture

Some one fix this bug?
We can modify source code directly )(PHP saying IF Node-type == 'my group type' && Menu Item == 'View' - THEN menu title == 'Home').) but it seems.... uggly
anyone?

tks!

Warning: This code is not

briwood's picture

Warning: This code is not exactly right. I'm posting it so you can play with it. I haven't had time to refine this modification yet.

You add something like this to template.php. Replace YOUR_THEMENAME with the name of your theme. You are overriding a function here. If you are not sure what that means, you should research that.

You also need to understand what og_get_group_context does. You can read the og.module code to learn about that.

I encourage someone to post a better solution! :-)

<?php
function YOUR_THEMENAME_menu_local_tasks() {
 
$output = '';
 
  if (
$primary = menu_primary_local_tasks()) {
 
   
$og_context = og_get_group_context();
   
    if(
og_is_group_type($og_context->type)){
     
$primary_edit = preg_replace("/(.<em>)(View)(.</em>)/", "$1Home$3", $primary);
     
$output .= "<ul class=\"tabs primary\">\n". $primary_edit ."</ul>\n";
    }

  }
 
  return
$output;
?>

Thanks for the snippet. I

cglusky's picture

Thanks for the snippet. I simplyfied a bit for garland:

<?php
/* Changing the view tab in og */
function garland_menu_local_tasks() {
 
$output = '';
 
  if (
$primary = menu_primary_local_tasks()) {
   
$og_context = og_get_group_context();
    if(
og_is_group_type($og_context->type)){
     
$output = str_replace("View", "Tasks", $primary);
    }
  }
 
  return
$output;
}
?>

[EDIT] This does not check for the existence of the og module and probably should to be safe.

breaks the user profile -

cglusky's picture

breaks the user profile - looks like i need to do more homework.

[EDIT] probably breaking a few coding standards with this but it seems to work

<?php
/* Changing the view tab in og */
function garland_menu_local_tasks() {
 
$output = '';
 
  if (
$primary = menu_primary_local_tasks()) {
   
$og_context = og_get_group_context();
    if(
og_is_group_type($og_context->type)){
     
$output .= str_replace("View", "Tasks", $primary);
      return
$output;
    }
  }
  return
menu_primary_local_tasks(); 
}
?>

Cglusky, I was wondering if

Janam's picture

Cglusky,

I was wondering if you could explain your code a bit. I'm pretty new to template files etc., so I'm not quite sure what your code is doing.

Thanks!

sztipam's picture

I am not sure if this helps this discussion, but I have a solution for OG tabs only showing for OG members and only when the OG Panel pages (tied to these OG tabs) have been published.
In the og_panels.module there is a function called - _og_panels_node_access
edit it to be:
<?
function _og_panels_node_access($nid, $tab_num) {
$tab = og_panels_node_data($nid, $tab_num);
if (isset($tab['nid'])) {
if (!empty($tab['default_page'])) {
// A bit counter-intuitive.
// This prevents duplicate tabs from showing up when we override the "view" title.
// Because we get that panel through our page_manager task_handler, and not a direct
// menu callback.
return FALSE;
}

$node = node_load($nid);

// if ($tab['published']) {
if (is_member($nid)) {
return node_access('view', $node);
}
if ($tab['published']) {
return node_access('view', $node);
}
// }

}
else {
return FALSE;
}

}

function is_member($nid) {
global $user;

$link = mysql_connect("localhost","vocypher","vocypher");
mysql_select_db("vocypher",$link);

$q = "select uid from users where name = '".$user->name."'";
$r = mysql_query($q,$link);
$uid = mysql_result($r,0,0);

$q = "select * from og_uid where nid = '".$nid."' and uid = '".$uid."'";
$r = mysql_query($q,$link);

if (!mysql_errno()) {
if (mysql_num_rows($r)>0) {
return 1;
}
else {
return 0;
}
}

}
?>
As you can see it now checks for both 'publish'-ness and membership.
HEY