Issue description

1. Create a custom home page using og_panels
2. Set the custom page as the groups home page
Result: An "Access Denied" message is displayed.

No help exists to overcome this.

There is a need to create/add a howto to describe how to setup a custom home page using og_panels that informs users that they MUST go to the Adminster >Site building>Pages and Enable System node_edit and system node_view. Once this is done you are able to see the home page correctly.

Comments

jimthunderbird’s picture

I just got this problem on a fresh Drupal 6.16 install with og_panels, trying to track it down and provide a fix for it without users having to going to the admin/build/page...

jimthunderbird’s picture

Here is one way to let og_panels bypass the node_view settings in admin/build/page.

1. In og_panels.module, add a new function at the end

function og_panels_og_homepage(){
  if(arg(0) == 'node' && arg(1) > 0){
    $node = node_load((int)arg(1));
    if(og_is_group_type($node->type)){
      #homepage always is tab 1
      $output = og_panels_page($node->nid, 1, FALSE);
      return $output;
    }
  }
}

2. In function og_panels_menu_alter, at the beginning add:

$items['node/%node'] = array(
    'page callback' => 'og_panels_og_homepage',
    'type' => MENU_CALLBACK,
    'access callback' => 'og_panels_access_admin',
    'access arguments' => array(1),
 );
jimthunderbird’s picture

The solution above has a problem, it will cause group post not showing up properly, here is an improved solution:

1. In og_panels.module, add a new function at the end

function og_panels_og_homepage(){
  if(arg(0) == 'node' && arg(1) > 0){
    $node = node_load((int)arg(1));
    if(og_is_group_type($node->type)){
      #homepage always is tab 1
      $output = og_panels_page($node->nid, 1, FALSE);
      return $output;
    }
    else{
      $output = node_page_view($node);
      return $output;
    }
  }
}

2. In function og_panels_menu_alter, at the beginning add:

$items['node/%node'] = array(
    'page callback' => 'og_panels_og_homepage',
    'type' => MENU_CALLBACK,
    'access callback' => 'node_access',
    'access arguments' => array('view', 1),
  );
jimthunderbird’s picture

The solution above, while works, will not allow node_view template to be enabled again. After a second thought, I guess implementing hook_init and put an error message on the group homepage will just do the trick:

function og_panels_init(){
  if( arg(0) == 'node' && arg(1) > 0){
      $group_node = node_load(arg(1));
      if (og_is_group_type($group_node->type)) {
        if( (arg(2) == "" || arg(2) == 'view') && variable_get('page_manager_node_view_disabled',0) == 1){
          drupal_set_message(t("In order to view the homepage, you need to enable node_view template, click ").'<a href="'.url("admin/build/pages/nojs/enable/node_view", array("query"=>"destination=node/$group_node->nid")).'">'.t("here").'</a> '.t("to enable."),"error");
        }
      }
  }
}
populist’s picture

Status: Active » Fixed

there may be a better way, but adding this in for now for -dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.