core hook to get group list and modify the list view

I want to get elgg group list through a plugin hook and want to modify the list to match my requirement. How can I do that? I need a source code example to modify the group list view and make a custom list for groups/all.

Thanks everyone

  • I think, you can hook group router, e.g :
     
    elgg_register_plugin_hook_handler('route', 'groups', 'group_list_custom', 999);
     
    function group_list_custom($hook, $type, $return, $params) {
    
    
    if (!is_array($return)) {
    
    return;
    
    }
    
    
    $segments = elgg_extract('segments', $return);
    
    
    $page = array_shift($segments);
    
    if (!$page) {
    
    $page = 'all';
    
    }
    
    
    if($page != 'all') return;
    
    // my custom list
    echo elgg_view('resources/groups/custom');
    
    return false;
    
    }
  • Thanks a lot Prase. But seems in your example I have to write a resource page and there I have to generate the full page and list. But is there any way only access the group list as a array and modify it? Without touching or modifying a view?