Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Aiheen aloitti: timned88 - helmikuu 16, 2009, 11:03:48 IP

Otsikko: is it possible to export stats from the stats page to forum index?
Kirjoitti: timned88 - helmikuu 16, 2009, 11:03:48 IP
for example. is it possible to have the top posters and their totals, etc. exported to the forum index page near the info center?
i understand it would go in board index but how would i do that?
Otsikko: Re: is it possible to export stats from the stats page to forum index?
Kirjoitti: timned88 - helmikuu 16, 2009, 11:46:16 IP
i have been able to get THIS far copy/pasting code from the stats.template.php to boardindex.template.php...   but none of the data values are passed thru.  what am i missing here?


if (!empty($modSettings['hitStats']))
      echo ' 
     <table> <tr>
<td class="catbg" colspan="2" width="50%"><b>', $txt['top_posters_day'], '</b></td>
<td class="catbg" colspan="2" width="50%"><b>', $txt['top_posters_week'], '</b></td>
</tr><tr>
<td class="windowbg" width="20" valign="middle" align="center"><img src="', $settings['images_url'], '/stats_posters.gif" width="20" height="20" alt="" /></td>
<td class="windowbg2" width="50%" valign="top">
<table border="0" cellpadding="1" cellspacing="0" width="100%">';
foreach ($context['top_posters_week'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['num_posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
<td width="20%" align="right" valign="top">', $poster['num_posts'], '</td>
</tr>';
echo '
</table>
</td>
<td class="windowbg" width="20" valign="middle" align="center" nowrap="nowrap"><img src="', $settings['images_url'], '/stats_posters.gif" width="20" height="20" alt="" /></td>
<td class="windowbg2" width="50%" valign="top">
<table border="0" cellpadding="1" cellspacing="0" width="100%">';
foreach ($context['top_posters_month'] as $poster)
echo '
<tr>
<td width="60%" valign="top">', $poster['link'], '</td>
<td width="20%" align="left" valign="top">', $poster['num_posts'] > 0 ? '<img src="' . $settings['images_url'] . '/bar.gif" width="' . $poster['post_percent'] . '" height="15" alt="" />' : '&nbsp;', '</td>
<td width="20%" align="right" valign="top">', $poster['num_posts'], '</td>
</tr>';
echo '
</table>
</td>
</tr>';


the screenshot shows what it looks like so far....  i can move it inside some of the div's once i get the data to pass thru properly.
Otsikko: Re: is it possible to export stats from the stats page to forum index?
Kirjoitti: karlbenson - helmikuu 17, 2009, 06:10:53 AP
That data is only queried on the Stats page in the Sources/Stats.php file.

Generally it wouldn't be recommended to do what you wanting to do.
Some of the stats querys are extremely intensive and if put on a common page like the boardindex, it will likely add considerable load to your forum.
Otsikko: Re: is it possible to export stats from the stats page to forum index?
Kirjoitti: Rumbaar - maaliskuu 07, 2009, 07:16:04 IP
As suggested, it's not recommended due to the unnecessary load on your server.  But look to the $source/Stats.php page for the actual data generating queries.