Only display this months data in Ushahidi

This is a simple hack to make Ushahidi display only the current months worth of data. This is useful if you have a large dataset with no real need to display historical data to your users.

Modify application/controllers/main.php lines 327 onwards.

                /* Commented out by John McLear */
                // $first_month = 1;
                // $last_month = 12;

                /* Added by John McLear as to only show the current month of data */
                $first_month = date('m');
                $last_month = date('m');
                /* End of new code */

                $i = 0;

                foreach ($query as $data)
                {
                        $date = explode('-',$data->dates);

                        $year = $date[0];
                        $month = $date[1];

                        /* Added by John McLear */
                        // Only includes from the month we are in now, yes this sucks but it works
                        if ($month == $first_month){

                                // Set first year
                                if($i == 0)
                                {
                                        $first_year = $year;
                                        $first_month = $month;
                                }

                                // Set last dates
                                $last_year = $year;
                                $last_month = $month;
                        }

                        $i++;
                }

2 thoughts on “Only display this months data in Ushahidi

  1. Hello,

    Sorry for coming here, but i’m a bit desperate with my Ushahidi. (badia-initiative.org).

    The filter is not working at all. Color is not changing and the filter neither.

    Could you have any ideas to help me?

    Thanks in advance!

    Eduardo

Leave a Reply

Your email address will not be published. Required fields are marked *