Hi all. I want to make a block which will appear in every group of my site containing some links regarding the group. The links i want to display are

og/users/%/list
and

node/add/%/add_member .

I notice that the argument is the node id of the current group. I don't know php and i imagine that i need to make a link like this

<?php print l("Add group member","og/users"nid of the current group"add_memeber"); ?>.

Can anyone please tell me how to achieve this? Thanks in advance.

Comments

nevets’s picture

Are you aware that og come with blocks, one of them includes those links.

paul555’s picture

Thank you for your answer. I know that og has some blocks with many links including those i want. I just want to make a navigation block with some other links pointing to some paths and the two links regarding the groups i mention above. Is this possible?

nevets’s picture

I believe this will work

<?php
$group = og_determine_context();
if ( !empty($group) ) {
  print l("Add group member","og/users/" . $group->nid . "/add_memeber");
}
?>
eliasdelatorre’s picture

I think that og_determine_context(); is already being called on og_init(); that means that is called on every request. And og_inits() set the group context with the function og_set_group_context in a static variable, so you can actually retrieve the context using og_get_group_context, which is cheaper than og_determine_context.

Bottom line, to get the group context you should use og_get_group_context:

$group = og_get_group_context();
if ( !empty($group) ) {
  print l("Add group member","og/users/" . $group->nid . "/add_memeber");
}
jan101’s picture

For OG 1.x Drupal7:

$group = og_context();
if ( !empty($group) ) {
  print $group->gid;
}