Is it possible? Eliminating the need to select the group on creating content.

Thanks for this great module!

Comments

MarcElbichon’s picture

What is your need exactly ?
You want to add gid param in the redirect url in the combo box ?

I don't know organic group. How can i get the group id of the current node ? From the url ?
Does url always gids[0]=xxxxx or can be gids[x]=xxx ?

soulfroys’s picture

You want to add gid param in the redirect url in the combo box ?

Exactly. I used the code below (book_made_simple.module) and it worked, but ... I am a newbie in Drupal.

$newUrl =  $url ."\" + this.value + \"" . $op . "parent=" . $node->book["mlid"];

  if (module_exists('og')) {
    $group_node = og_get_group_context();
    if ($group_node && og_is_group_member($group_node)) {
      $group_query = '&gids[]=' . $group_node->nid;
    }
  }

	return "<select onchange='location.href=\"" . $newUrl . $group_query . "\"'>$html</select>";

Thanks for your reply!

MarcElbichon’s picture

Commited to 6 and 7 dev version.
Thank for your contribution

soulfroys’s picture

Title: Integration with organic groups module: node/add/[type]?gids[0]=[gid] » Integration with organic groups module: node/add/[type]?gids[]=[gid]
Status: Active » Needs review

I'm glad that my suggestion has been Committed! I removed the "zero" of the title (I don't know where it came from).

Someone else needs this integration?

soulfroys’s picture

StatusFileSize
new1.56 KB

The last commit has some errors. I made the necessary modifications (attached patch).

Note: I am newbie in Drupal/PHP.

MarcElbichon’s picture

Sorry.
Committed to dev version.

soulfroys’s picture

StatusFileSize
new1.64 KB

I'm sorry too, I forgot to change your code in line 484. Follow new "diff" (I don't have GIT) file for last dev (6.x-3.x-dev - 2011-Dec-13).

MarcElbichon’s picture

Query parameter can be either a string or an array. I've replaced line 488

 $query['&gids[]'] =  $group_node->nid;

by

 $query['gids[]'] =  $group_node->nid;

I've commited a new version, but you can do the update yourself if you want.
Tell me back if it works (or not !)

soulfroys’s picture

You're right, so the bellow modifications are unnecessary:

         foreach ($allowedTypes as $type => $name ) {
-          $query = array("parent" => $node->book['mlid']);
+          $query = "parent=" . $node->book['mlid'];
           if (module_exists('og')) {

The Internet Explorer gives us an ugly url, but it works!

?parent=123725&gids%5B%5D=3071
MarcElbichon’s picture

Status: Needs review » Fixed
MarcElbichon’s picture

Status: Fixed » Closed (fixed)
MarcElbichon’s picture

Project: Book made simple (Obsolete) » Book made simple
keyiyek’s picture

Does this work for version 7.x?
I'm trying to set it with no luck. My url, doesn't get changed. It seems the line

if ($group_node && og_is_member($group_node)) {

is returning false.

I also seen that the "create content link" from og modify the path with the string

&og_group_ref=&

I know og has changed drastically recently, maybe this is due to that.