How to combine Own + Following river activity tabs into one

@iionly told me how to remove tabs and @tunist gave few suggestions on what I want to achieve. I want to combine "mine" and "following" tabs into 1 tab. I am not using friends functionality. I have installed followers plugin. I am using elgg 1.11.2. A rookie (non-developer) like me will say ok why not paste the code from the file responsible for "following" tab to "mine" tab. I do not know. Looking for help from the community. @tunist gave following suggestions.

if i were going to code a solution for this i would:

  1. find the part in the elgg code that draws the activity page
  2. identify the parts of the code that add the various tabs into that page
  3. create a view/page that produces the river list with the required data (mine + followed)
  4. find a way to remove the other tabs that are not wanted
  5. add the new river view/tab to the activity page

i imagine this might be done most effectively using plugin hooks, but i don't have a lot of experience with these so that's why my suggestion is to ask in the community ;)

  • Ordering achieved finally with:

    This function (you must add it in your plugin lib path)

    function cmp_activity($a1, $a2)
            {
                    if ($a1->posted === $a2->posted)
                            return 0;

                    return ($a1->posted < $a2->posted ? -1 : 1);
            }

    This code in river.php

    $riveritems = array_merge($activityg, $activityf);
    usort($riveritems, 'cmp_activity');    
    $riveritems = array_reverse($riveritems);     

    BUT I´ve an issue, activity pagination doesn´t work, I tryed changing some of these parameters but without results

    $activity = elgg_view("page/components/list", array(
                "list_id" => 'all_activity',  //Necesario para evitar problemas en el refresco
                "pagination" => true,  //JSA para que refresque el widget cuando posteas en hypeWall
               // "auto_refresh" => 15,  //JSA para que refresque cada 15seg 
                "count" => count($riveritems),
                "items" => $riveritems,
                "list_class" => "elgg-list-river elgg-river",
                //"offset" => 10,
            ));        

    Any idea about the reason??

       

  • no idea. Sorry for replying late.

  • This is my last code, but pagination still doesn´t work (all activity items are displayed at the same time) Please help!

        default:
            $title = elgg_echo('river:all');
            $user = elgg_get_logged_in_user_entity();
            $db_prefix = elgg_get_config('dbprefix');
            $page_filter = 'all';

            if ($user) {
                $groups = $user->getGroups(array(), false);
                $group_guids = array();
                foreach ($groups as $group) {
                    $group_guids[] = $group->getGUID();
                }
            }
            $guids_in = implode(',', array_unique(array_filter($group_guids)));    
            //Groups activity
            $options['joins'] = array("JOIN {$db_prefix}entities e ON e.guid = rv.object_guid");
            $options['wheres'] = array("e.container_guid IN({$guids_in})");
            $options['limit'] = 0;    
            $activityg = elgg_get_river($options);
            $options['count'] = true;
            $activityg_count = elgg_get_river($options);
            //Friends activity
            $optionsf['relationship_guid'] = elgg_get_logged_in_user_guid();
            $optionsf['relationship'] = 'friend';        
            $optionsf['limit'] = 0;    
            $activityf = elgg_get_river($optionsf);
            $optionsf['count'] = true;
            $activityf_count = elgg_get_river($options);
            echo $riveritems_count = $activityf_count + $activityg_count;
            //Merge and short by date
            $riveritems = array_merge($activityg, $activityf);
            usort($riveritems, 'cmp_activity');    
            $riveritems = array_reverse($riveritems);    
            
            
            $activity = elgg_view("page/components/list", array(
                "list_id" => 'all_activity',  //Necesario para evitar problemas en el refresco
                "pagination" => true,  //JSA para que refresque el widget cuando posteas en hypeWall
               // "auto_refresh" => 15,  //JSA para que refresque cada 15seg 
                "count" => $riveritems_count,
                "items" => $riveritems,
                "list_class" => "elgg-list-river elgg-river",
                "limit" => 20,
                //'reversed' => true
            ));        
            
            break;
    }
            
    //$activity = elgg_list_river($options);
    if (!$activity) {
        $activity = elgg_echo('river:none');
    }

    $content = elgg_view('core/river/filter', array('selector' => $selector));
    $content .= $activity;

    $sidebar = elgg_view('core/river/sidebar');

    $params = array(
        'title' => $title,
        'content' =>  $content,
        'sidebar' => $sidebar,
        'filter_context' => $page_filter,
        'class' => 'elgg-river-layout',
    );

    $body = elgg_view_layout('content', $params);

    echo elgg_view_page($title, $body);

  • Finally I think I´ve achieved it!!!

     

    default:
            $title = elgg_echo('river:all');
            $user = elgg_get_logged_in_user_entity();
            $db_prefix = elgg_get_config('dbprefix');
            $page_filter = 'all';

            if ($user) {
                $groups = $user->getGroups(array(), false);
                $group_guids = array();
                foreach ($groups as $group) {
                    $group_guids[] = $group->getGUID();
                }
            }
            $guids_in = implode(',', array_unique(array_filter($group_guids)));                    
            $options['joins'] = array("JOIN {$db_prefix}entities e ON e.guid = rv.object_guid");
            //Groups + Friends activity query
            $options['wheres'] = array("        
            e.container_guid IN({$guids_in})
            OR rv.subject_guid IN (SELECT guid_two FROM {$db_prefix}entity_relationships WHERE guid_one=$user->guid AND relationship='friend')
            ");
                    
            break;
    }
            
    $activity = elgg_list_river($options);

    if (!$activity) {
        $activity = elgg_echo('river:none');
    }

    $content = elgg_view('core/river/filter', array('selector' => $selector));

    $sidebar = elgg_view('core/river/sidebar');

    $params = array(
        'title' => $title,
        'content' =>  $content . $activity,
        'sidebar' => $sidebar,
        'filter_context' => $page_filter,
        'class' => 'elgg-river-layout',
    );

    $body = elgg_view_layout('content', $params);

    echo elgg_view_page($title, $body);