Posted by leoklein on July 27, 2008 at 5:06pm
I'm building a community site for the Public Librarians and I was wondering how on Wiki Pages, the Edit link is added on Drupal Groups.
It's the link just under the Title that says, "You are viewing a wiki page. You are welcome..." Then depending on whether you're already a member of the Group, the link either goes to edit the page or join the group.
How nice.
Does anyone know how this was done? Is it something added to the theme template? I'm trying to figure out how it's done!
Any help would be appreciated.

Comments
I don't know how exactly how
I don't know how exactly how this is done on g.d.o, but I would do this via the theming layer -- the easiest way would probably be to add this into a custom tpl.php file.
Cheers,
Bill
FunnyMonkey
Tools for Teachers
FunnyMonkey
Hacktacular Success
Okay, this is what I came up with. Comments are welcome:
<!-- added to theme's page template right after 'message' by leo --><?php
// are we viewing a single node?
if ( arg(0) == 'node' && is_numeric(arg(1)) && !arg(2) ) {
// viewing a single node, get the node
$node = node_load(arg(1));
// test for node type
if ( $node->type == 'wiki') {
global $user;
$currentGroup = $node->og_groups;
$userGroups = $user->og_groups;
print '<div class="messages status">';
// test if user is authenticated and member of group
if (in_array('authenticated user',$user->roles) && $userGroups[$currentGroup[0]]) {
print'You are viewing a wiki page. You are welcome to <a href="/node/';
print arg(1);
print '/edit">edit it</a>.';
print '</div>';
}
else {
print'You are viewing a wiki page. You are welcome to <a href="/og/subscribe/';
print $currentGroup[0];
print '?destination=node/';
print arg(1);
print '"> join the group and then edit it</a>.';
}
print '</div>';
}
}
?>
<!-- end added by leo -->
I don't think the testing to see if the user is a member of the current group -- or the way the 'print' command has to be on so many different lines, is particular elegant.