News:

Wondering if this will always be free?  See why free is better.

Main Menu

/forum/index.php?action=stats with DAY info

Started by SMiFFER, October 17, 2018, 06:55:52 AM

Previous topic - Next topic

SMiFFER

The daily stats list the date as

2018-10-17
2018-10-16
2018-10-15

I would like to have them with the 3-letter-day mentioned, example:

2018-10-17 WED
2018-10-16 TUE
2018-10-15 MON

How can I get that done?
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

vii

You need to make a few direct modifications. I whipped this up quick and did a quick test to confirm it works:

Sources/Stats.php, Find:


   // Activity by day.
   $days_result = $smcFunc['db_query']('', '
      SELECT YEAR(date) AS stats_year, MONTH(date) AS stats_month, DAYOFMONTH(date) AS stats_day, topics, posts, registers, most_on, hits
      FROM {db_prefix}log_activity
      WHERE ' . $condition_string . '
      ORDER BY stats_day ASC',
      $condition_parameters
   );
   while ($row_days = $smcFunc['db_fetch_assoc']($days_result))
      $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
         'day' => sprintf('%02d', $row_days['stats_day']),


Replace with:


   // Activity by day.
   $days_result = $smcFunc['db_query']('', '
      SELECT YEAR(date) AS stats_year, MONTH(date) AS stats_month, DAYOFMONTH(date) AS stats_day, topics, posts, registers, most_on, hits
      FROM {db_prefix}log_activity
      WHERE ' . $condition_string . '
      ORDER BY stats_day ASC',
      $condition_parameters
   );
   while ($row_days = $smcFunc['db_fetch_assoc']($days_result))
      $context['yearly'][$row_days['stats_year']]['months'][(int) $row_days['stats_month']]['days'][] = array(
         'day_word' => strtoupper(date('D', strtotime($row_days['stats_day'] . '-' . $row_days['stats_month'] . '-' . $row_days['stats_year']))),
         'day' => sprintf('%02d', $row_days['stats_day']),



Themes/default/Stats.template.php, find:


               foreach ($month['days'] as $day)
               {
                  echo '
            <tr class="windowbg2" valign="middle" align="center" id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '">
               <td class="stats_day">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>


Replace with:


               foreach ($month['days'] as $day)
               {
                  echo '
            <tr class="windowbg2" valign="middle" align="center" id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '">
               <td class="stats_day">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>


Themes/default/Xml.template.php, find:


            echo '
      <day date="', $day['year'], '-', $day['month'], '-', $day['day'], '" new_topics="', $day['new_topics'], '" new_posts="', $day['new_posts'], '" new_members="', $day['new_members'], '" most_members_online="', $day['most_members_online'], '"', empty($modSettings['hitStats']) ? '' : ' hits="' . $day['hits'] . '"', ' />';



            echo '
      <day date="', $day['year'], '-', $day['month'], '-', $day['day'], ' ', $day['day_word'], '" new_topics="', $day['new_topics'], '" new_posts="', $day['new_posts'], '" new_members="', $day['new_members'], '" most_members_online="', $day['most_members_online'], '"', empty($modSettings['hitStats']) ? '' : ' hits="' . $day['hits'] . '"', ' />';


The last modification is to ensure it still lists the day string when you expand months on the page (vs refreshing the entire thing)
The way I calculated the day is not ideal but whatever. You could also just take the code 'day_word' code from the first modification and use it in the last two, thus cutting the # of direct mods from 3 to 2, but I figure it is more consistent to do it this way.

Shambles

Good work V.

Your "before" and "after" in this section are identical/ Did you miss something out?


vii

#3
!! CORRECTION !!

Themes/default/Stats.template.php, find:


               foreach ($month['days'] as $day)
               {
                  echo '
            <tr class="windowbg2" valign="middle" align="center" id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '">
               <td class="stats_day">', $day['year'], '-', $day['month'], '-', $day['day'], '</td>


Replace with:


               foreach ($month['days'] as $day)
               {
                  echo '
            <tr class="windowbg2" valign="middle" align="center" id="tr_day_', $day['year'], '-', $day['month'], '-', $day['day'], '">
               <td class="stats_day">', $day['year'], '-', $day['month'], '-', $day['day'], ' ', $day['day_word'], '</td>



Yes, thank you Sh@mbles! I was in a hurry and I forgot to update that part, and now I can't because of the max edit time. I also reset all my files. smh.

That should cover it.

Advertisement: