MyBB Community Forums

Full Version: extra stats in index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I tried make an extra table of stats by adding this code
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->most_popular}</strong></td>
</tr>
<tr>
<td class="tcat" width="50%"><strong>{$lang->most_replied_threads}</strong></td>
<td class="tcat" width="50%"><strong>{$lang->most_viewed_threads}</strong></td>
</tr>
<tr>
<td class="trow1" valign="top">{$mostreplies}</td>
<td class="trow1" valign="top">{$mostviews}</td>
</tr>
</table>

any idea why it wont work?
Are you trying to make your own mod or you are implementing a part of a current mod?

Because obviously empty variables results empty output!! there should be a php code with this. If you don't have it... tell me i will do one for you.

regards
zaher1988 Wrote:Are you trying to make your own mod or you are implementing a part of a current mod?

Because obviously empty variables results empty output!! there should be a php code with this. If you don't have it... tell me i will do one for you.

regards

I was trying to make it so that the most replied to threads, and most viewed threads showed up at the bottom of my index. I took the code right from the stats template. I really have no idea what I am doing with coding so I didnt realize that there are empty variables here. Any help would be apreciated.
In index.php

Find
eval("\$forumstats = \"".$templates->get("index_stats")."\";");

Above it add
	// Most replied-to threads
	$query = $db->simple_select(TABLE_PREFIX."threads", "tid, subject, replies", $fidnot, array('order_by' => 'replies', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));
	while($thread = $db->fetch_array($query))
	{
		$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
		$numberbit = my_number_format($thread['replies']);
		$numbertype = $lang->replies;
		eval("\$mostreplies .= \"".$templates->get("stats_thread")."\";");
	}
	
	// Most viewed threads
	$query = $db->simple_select(TABLE_PREFIX."threads", "tid, subject, views", $fidnot, array('order_by' => 'views', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));
	while($thread = $db->fetch_array($query))
	{
		$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
		$numberbit = my_number_format($thread['views']);
		$numbertype = $lang->views;
		eval("\$mostviews .= \"".$templates->get("stats_thread")."\";");
	}

Your template codes should be in index_stats template.

In code you have showen in the 1st post, i see you have used lang variables. Those wont work the way they are, you may edit the index lang file to type the text manually in the template codes.


This will give 2 lists... one is a list of the most viewed thread.. another for the most replied.
zaher1988 Wrote:In index.php

Find
eval("\$forumstats = \"".$templates->get("index_stats")."\";");

Above it add
	// Most replied-to threads
	$query = $db->simple_select(TABLE_PREFIX."threads", "tid, subject, replies", $fidnot, array('order_by' => 'replies', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));
	while($thread = $db->fetch_array($query))
	{
		$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
		$numberbit = my_number_format($thread['replies']);
		$numbertype = $lang->replies;
		eval("\$mostreplies .= \"".$templates->get("stats_thread")."\";");
	}
	
	// Most viewed threads
	$query = $db->simple_select(TABLE_PREFIX."threads", "tid, subject, views", $fidnot, array('order_by' => 'views', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));
	while($thread = $db->fetch_array($query))
	{
		$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
		$numberbit = my_number_format($thread['views']);
		$numbertype = $lang->views;
		eval("\$mostviews .= \"".$templates->get("stats_thread")."\";");
	}

Your template codes should be in index_stats template.

In code you have showen in the 1st post, i see you have used lang variables. Those wont work the way they are, you may edit the index lang file to type the text manually in the template codes.


This will give 2 lists... one is a list of the most viewed thread.. another for the most replied.

so I should ignore my old code and just put this in and it will work?
Yes obviously