i have written a code to get details of groups which are joined by the user ... but how to differentiate between child and parent...? please help me out for that...
function groups_yours_menu() {
$viewer = elgg_get_logged_in_user_entity();
//read viewer's groups
$content = elgg_get_entities_from_relationship(array(
'type' => 'group',
'relationship' => 'member',
'relationship_guid' => elgg_get_logged_in_user_guid(),
'inverse_relationship' => false,
'limit' => 0,
));
//create array of entries ($content object had duplicate entries, array keys prevent duplicates (sry for being lazy)
$groupmenu_array = Array();
foreach ($content as $mygroup) {
$groupmenu_array[(string)$mygroup->get('guid')] = $mygroup->get('name');
//print_r ($mygroup);
}
//sort array while keeping the IDs
asort($groupmenu_array);
//create HTML code out of array
foreach ($groupmenu_array as $group_guid=>$group_name) {
$groupmenu .= '<div>'.elgg_view('output/url', array('href' => "groups/profile/$group_guid",'text' => $group_name, 'is_trusted' => true,)).'</a></div>';
}
//add wrapping divs around menu and logo (</a> to close link generated by register_menu_item)
/*$groupmenu = '</a><div id="topbar-mygroups" style="height:22px;">'. elgg_view('output/url', array('href' => "groups/member/{$viewer->username}",'text' => elgg_view_icon('share'), 'is_trusted' => true, 'title' => 'Your groups')) . '<div id="topbar-groupmenu" style="display:none; position:absolute; background-color:#EEEEEE; white-space:nowrap; padding:3px; margin-top: 4px;">' . $groupmenu . '</div></div><a>';*/
//adding the new menu to the topbar
$value = array(
'name' => 'mygroups',
'href' => "",
'text' => $groupmenu,
'title' => elgg_echo('groups:yours'),
'priority' => 250,
);
// echo "<br><br>";
// var_dump($value);
elgg_register_menu_item('site', $value);
Interesting...!!
I would also like to know about it.
There are some functions in the plugin you can use, I don't remember them offhand but you should be able to find them by their names in lib/functions.php
It will be something like au_subgroups_get_children($group)
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.