In spaces 2.x the group node page was redirected to its space frontpage. In 3.x that functionality was removed. But I liked that functionality. I've written a nodeapi tweak to restore it but it'd be good to have an option in spaces itself to turn on this functionality if needed.

Here's my nodeapi code in case anyone has the same problem:


/*
 * Implementation of hook_nodeapi().
 * Redirect group nodes to their space homepage.
 */
function eduglu_groups_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == "view" && $node->type == "group") {
    $space = spaces_get_space();
    drupal_goto($node->purl . "/" . $space->controllers->variable->values['space']['site_frontpage']);
  }
}
CommentFileSizeAuthor
#5 og_space_frontpage.zip1.93 KBamstel

Comments

MichaelP’s picture

Nice one, just in time!

Thanks.

MichaelP’s picture

Actually, revisiting this because I've now determined I don't have a use for it (not to say others don't either).

I had thought I had because:

Views links were taking users to the node page. But obviously (now) the link must be of type "Node: Group Space" in order to point to the group home (The clickbox "link this field to its node" is a false friend here).

If the group name is the same as the (spaces) path, the user is taken to the node page, instead of the group home when requesting the url. But that would seem ok too, we are getting around that one using a pathauto pattern to make the node path different from the space path.

So all is well, users land on the group homepage, and we can also "view" the group profile page when requested specifically.

jmiccolis’s picture

Status: Active » Closed (works as designed)

As MichaelP said:

So all is well, users land on the group homepage, and we can also "view" the group profile page when requested specifically.

Couldn't have put it better myself. This is exactly the behavior we want, and I think it's absolutely fine is distro's like eduglu have a couple lines of code to force people to the site's front page. The other way around, where you couldn't get to the node page, would be much more troublesome.

kyle_mathews’s picture

A quick update to my code to redirect the group node to the frontpage of the space as the previous implementation was broken:


/**
 * Implementation of hook_nodeapi().
 **/
function eduglu_groups_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  // Check if we're looking at a group node (which we don't want to do).
  // If we are, find the Space frontpage path and redirect there.
  if (og_is_group_type($node->type) && $op == "load" && arg(0) == 'node' && is_numeric(arg(1))) {
    $page_nid = arg(1);
    if ($page_nid == $node->nid) {
      // Grab the PURL value for this group.
      $purl = purl_load(array('provider' => 'spaces_og', 'id' => $node->nid));
      drupal_goto($purl['value']);
    }
  }
}
amstel’s picture

StatusFileSize
new1.93 KB

I created a simple module to offer this functionality based on the code above.