Your groups topbar menu v0.3

Release Notes


- closed unwanted <a> tag around the icon

- changed icon to "share" to have something different from friends

TODO (you're welcome to do that, you can contact me for a new release then)

- change hardcoded styles into stylesheet, improve design

  • Great plug-in, but there is a little problem with the Facebook theme that causes to don't displaying correctly. I done some editions to the script to display the items more elegant using the Facebook template.

    There is a modified version of start.php:

     * Dropdown menu for user's own groups
     * Modified by Davod to display the items more elegant using the Facebook template
    elgg_register_event_handler('init', 'system', 'groups_yours_menu');
    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,
    		'style' => 'height:10px',
    	//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
    	//create HTML code out of array
    	foreach ($groupmenu_array as $group_guid=>$group_name) {
    		$groupmenu .= '<li class="elgg-menu-item-notifications">'.elgg_view('output/url', array('href' => "groups/profile/$group_guid",'text' => $group_name,'is_trusted' => true,)).'</a></li>';
    	//add wrapping divs around menu and logo (</a> to close link generated by register_menu_item)
    	$groupmenu = '</a><div id="topbar-mygroups" onMouseOut="$(\'#topbar-groupmenu\').hide()" onMouseOver="$(\'#topbar-groupmenu\').show()" style="padding:8px 0;">'. elgg_view('output/url', array('href' => "groups/member/{$viewer->username}",'text' => elgg_view_icon('share'), 'is_trusted' => true, 'title' => 'My groups')) . '<div id="topbar-groupmenu" style="display:none; position:absolute; background-color:#EEEEEE; white-space:nowrap;top:32px"><ul class="elgg-menu elgg-child-menu elgg-state-active" style="position:relative !important;">' . $groupmenu . '</ul></div></div';
    	//adding the new menu to the topbar
    	elgg_register_menu_item('topbar', array(
    		'name' => 'mygroups',
    		'href' => "groups",
    		'text' => $groupmenu,
    		'title' => elgg_echo('groups:yours'),
    		'priority' => 5000, //To place the item to the right
    		'style' => 'width:0;height:0;padding:0;margin:0',

    Also, is necessary to enlarge the sidebar of the Facebook theme to fit all the items and searchbar.

    In mod/facebook_theme/views/default/css/elements/layout.php, find .elgg-sidebar {, and in the width property, replace with 210px !important; or any value to fit the tiems in the topbar.

    .elgg-sidebar {
        position: relative;
        padding: 20px 0;
        float: left;
        width: 210px !important>;
        min-height: 360px;

    In mod/facebook_theme/views/default/css/elements/forms.php, at the bottom of the file, add:

        margin: 4px 0 4px 210px !important;

    The value for the with of the abobe should be the same as the other abobe file.

  • Great plugin! My only issue is that it is kind of tough to select a group. When I scroll down the list, my site icon link tends to take over, closing the list. I need to move the cursor very fast to keep the list open. It would be nice if the list stayed open unless the user scrolled off the list.

  • i'd like to see this with the <div> <a> structure replaced with the <ul> <li> structure that is used for the .elgg-menu-hover elements presently; that way we can create a replicated style theme that matches other menus more easily.

  • to replace the divs with a list to allow full width hover effect, rather than just over the text, replace the relevant code in start.php with:

    //create HTML code out of array
    $groupmenu .= '<ul class="topbar-mygroups-list">';
    foreach ($groupmenu_array as $group_guid=>$group_name) {
    $groupmenu .= '<li>'.elgg_view('output/url', array('href' => "groups/profile/$group_guid",'text' => $group_name, 'is_trusted' => true,)).'</a></li>';

    $groupmenu .= '</ul>';
    //add wrapping divs around menu and logo (</a> to close link generated by register_menu_item)

  • the only thing i get is a long list of impossible to read text on the dropdown..
    any of the proposed code here on the comment fix this ?  

  • the code i shared changes the format of the list slightly and makes the presentation clearer. you can further edit the spacing and format using css rules in your theme plugin. 

  • how can i change the icon?

  • how can i change the topbar to a new menu list ??in left side ...!!

  • elgg_register_menu_item('site', array(
            'name' => 'mygroups',
            'href' => "",
            'text' => $groupmenu,
            'title' => elgg_echo('groups:yours'),
            'priority' => 250,

    Is this okie ??



  • perfect in elgg version 1.9.. congratulations


  • Category: Communication
  • License: GNU General Public License (GPL) version 2
  • Updated: 2014-11-17
  • Downloads: 1141
  • Recommendations: 7

Other Projects

View SehLax's plugins