Page 1 of 4

Top Stats

Posted: 06 Oct 2012, 23:02
by cabalganti
Hello Stoker.
I have a question . It is possible to implement the Active topics scrolling element (Top Stats addon, not the whole thing but the scrolling element) for each forum and displaying only the active topics for that forum?
Thanks in advance.

Top Stats

Posted: 07 Oct 2012, 06:50
by Stoker
Sounds like a standalone mod. Sorry, dont have time for that atm.

Top Stats

Posted: 07 Oct 2012, 07:28
by cabalganti
Oh i see.
Been playing with Top Stats, following the instructions in this post viewtopic.php?f=49&t=1956

So i move the edits on index.php to viewforum.php and the edit from index_body.html, to viewforum_body.html and they had no sucees and post is over 6 months old.


viewforum_body.html FIND

Code: Select all

<!-- INCLUDE forumlist_body.html -->
ADD BEFORE

Code: Select all

<!-- IF S_TSRAT_ENABLE -->
<!-- INCLUDE recent_active_body.html -->
<!-- ENDIF -->
I ignore the rest of the code because i only want the scrolling element.

The problem is with viewforum.php, i don't know where to place the code. Original install file says:

FIND

Code: Select all

// Output page
page_header($user->lang['INDEX']);
ADD BEFORE

Code: Select all

//-- mod: Top Stats ---------------------------------------------------------//
	include($phpbb_root_path . 'includes/functions_top_stats.' . $phpEx);
//-- end: Top Stats ---------------------------------------------------------//

I don't longer care about the recent active topics per forum, just want it to show on every forum.
Can you help Stoker? :?

Top Stats

Posted: 07 Oct 2012, 07:31
by Stoker
Try before: // Dump out the page header and load viewforum template

Top Stats

Posted: 07 Oct 2012, 07:37
by cabalganti
i get 2 errors:
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_top_stats.php on line 244: Division by zero
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_top_stats.php on line 204: Division by zero

Top Stats

Posted: 07 Oct 2012, 07:39
by cabalganti
It actually shows the scrolling element but with the 2 errors i mentioned before.

Top Stats

Posted: 07 Oct 2012, 11:26
by Stoker
Then open the topstats php file and copy the code for recent avtive to viewforum.php
Im not at home so I cant tell you the exact code

Top Stats

Posted: 07 Oct 2012, 12:09
by Stoker
This is the code you need to use on viewforum.php

Code: Select all

// Recent Active Topics
$flist = $auth->acl_getf('f_read', true);
$flist = array_unique(array_keys($flist));
$flist = array_merge($flist, array(0));
$enable_active_topics = (!empty($config['tsrat_enable']) ? true : false);
if ($enable_active_topics && sizeof($flist))
{	
	$sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_time, t.topic_views, t.topic_poster, t.topic_replies, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time, t.topic_last_view_time, t.topic_last_poster_id, f.forum_name, f.forum_image
		FROM ' . TOPICS_TABLE . ' t
		LEFT JOIN ' . FORUMS_TABLE . ' f ON (t.forum_id = f.forum_id)
		WHERE ' . $db->sql_in_set('t.forum_id', $flist) . ' AND t.topic_moved_id = 0 AND t.topic_approved = 1
		ORDER BY t.topic_last_post_time DESC';
	$result = $db->sql_query_limit($sql, $config['tsrat_number']);

	while ($row = $db->sql_fetchrow($result))
	{
		$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']);
		$view_last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id']);
		$view_first_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile' . '&u=' . $row['topic_poster']);
		$view_last_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile' . '&u=' . $row['topic_last_poster_id']);
		$view_viewforum_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
		
		$template->assign_block_vars('recent_active', array(
			'TOPIC_TITLE'					=> $row['topic_title'],
			'TOPIC_TIME'                    => $user->format_date($row['topic_time']), 
			'TOPIC_VIEWS'					=> $row['topic_views'],
			'TOPIC_REPLIES'					=> $row['topic_replies'],
			'TOPIC_FIRST_POSTER_NAME'		=> $row['topic_first_poster_name'],
			'TOPIC_FIRST_POSTER_COLOUR'		=> $row['topic_first_poster_colour'],
			'TOPIC_LAST_POSTER_NAME'		=> $row['topic_last_poster_name'],
			'TOPIC_LAST_POSTER_COLOUR'		=> $row['topic_last_poster_colour'],
			'TOPIC_LAST_POST_TIME'			=> $user->format_date($row['topic_last_post_time']),
			'TOPIC_LAST_VIEW_TIME'			=> $user->format_date($row['topic_last_view_time']),
			'U_FIRST_TOPIC'					=> $view_topic_url,
			'U_LAST_TOPIC'					=> $view_last_post_url,
			'USERNAME_FIRST'				=> $view_first_poster,
			'USERNAME_LAST'					=> $view_last_poster,
			'FORUM_NAME'					=> $row['forum_name'],
			'FORUM_IMAGE'					=> $row['forum_image'],
			'FORUM_URL'						=> $view_viewforum_url,
		));
	}
	$db->sql_freeresult($result);
	
	$template->assign_vars(array(
	//isset we can enter a value ?  : 'or leave empty' (value)
	//!empty yes : no ,true : false (bool)
        'JSSCROLL_SPEED'				=> (isset($config['tsjss_speed'])) ? $config['tsjss_speed'] : '',
		'JSSCROLL_INTERVAL'				=> (isset($config['tsjss_interval'])) ? $config['tsjss_interval'] : '',
		'TSRAT_NUMBER'					=> (isset($config['tsrat_number'])) ? $config['tsrat_number'] : '',
		'TS_JSSCROLL_DIRECTION'			=> (!empty($config['ts_jsscroll_direction'])) ? true : false,
		'TS_JSSCROLL_PAUSE'				=> (!empty($config['ts_jsscroll_pause'])) ? true : false,
		'TS_JSSCROLL_NAVIGATION'		=> (!empty($config['ts_jsscroll_navigation'])) ? true : false,
		'S_TSRAT_ENABLE'      			=> (!empty($config['tsrat_enable'])) ? true : false,
		'S_TS_JSSCROLL'      			=> (isset($config['ts_jsscroll'])) ? $config['ts_jsscroll'] : '',
		'S_TS_TICKER' 	     			=> (!empty($config['ts_ticker_enable'])) ? true : false,
    ));
}

Top Stats

Posted: 07 Oct 2012, 12:52
by cabalganti
Thank yo so much for answering. Still get the errors.
Added the following code before : // Dump out the page header and load viewforum template

Code: Select all

    // Recent Active Topics
    $flist = $auth->acl_getf('f_read', true);
    $flist = array_unique(array_keys($flist));
    $flist = array_merge($flist, array(0));
    $enable_active_topics = (!empty($config['tsrat_enable']) ? true : false);
    if ($enable_active_topics && sizeof($flist))
    {   
       $sql = 'SELECT t.forum_id, t.topic_id, t.topic_title, t.topic_time, t.topic_views, t.topic_poster, t.topic_replies, t.topic_first_poster_name, t.topic_first_poster_colour, t.topic_last_post_id, t.topic_last_poster_name, t.topic_last_poster_colour, t.topic_last_post_time, t.topic_last_view_time, t.topic_last_poster_id, f.forum_name, f.forum_image
          FROM ' . TOPICS_TABLE . ' t
          LEFT JOIN ' . FORUMS_TABLE . ' f ON (t.forum_id = f.forum_id)
          WHERE ' . $db->sql_in_set('t.forum_id', $flist) . ' AND t.topic_moved_id = 0 AND t.topic_approved = 1
          ORDER BY t.topic_last_post_time DESC';
       $result = $db->sql_query_limit($sql, $config['tsrat_number']);

       while ($row = $db->sql_fetchrow($result))
       {
          $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']);
          $view_last_post_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id']);
          $view_first_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile' . '&u=' . $row['topic_poster']);
          $view_last_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile' . '&u=' . $row['topic_last_poster_id']);
          $view_viewforum_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
          
          $template->assign_block_vars('recent_active', array(
             'TOPIC_TITLE'               => $row['topic_title'],
             'TOPIC_TIME'                    => $user->format_date($row['topic_time']),
             'TOPIC_VIEWS'               => $row['topic_views'],
             'TOPIC_REPLIES'               => $row['topic_replies'],
             'TOPIC_FIRST_POSTER_NAME'      => $row['topic_first_poster_name'],
             'TOPIC_FIRST_POSTER_COLOUR'      => $row['topic_first_poster_colour'],
             'TOPIC_LAST_POSTER_NAME'      => $row['topic_last_poster_name'],
             'TOPIC_LAST_POSTER_COLOUR'      => $row['topic_last_poster_colour'],
             'TOPIC_LAST_POST_TIME'         => $user->format_date($row['topic_last_post_time']),
             'TOPIC_LAST_VIEW_TIME'         => $user->format_date($row['topic_last_view_time']),
             'U_FIRST_TOPIC'               => $view_topic_url,
             'U_LAST_TOPIC'               => $view_last_post_url,
             'USERNAME_FIRST'            => $view_first_poster,
             'USERNAME_LAST'               => $view_last_poster,
             'FORUM_NAME'               => $row['forum_name'],
             'FORUM_IMAGE'               => $row['forum_image'],
             'FORUM_URL'                  => $view_viewforum_url,
          ));
       }
       $db->sql_freeresult($result);
       
       $template->assign_vars(array(
       //isset we can enter a value ?  : 'or leave empty' (value)
       //!empty yes : no ,true : false (bool)
            'JSSCROLL_SPEED'            => (isset($config['tsjss_speed'])) ? $config['tsjss_speed'] : '',
          'JSSCROLL_INTERVAL'            => (isset($config['tsjss_interval'])) ? $config['tsjss_interval'] : '',
          'TSRAT_NUMBER'               => (isset($config['tsrat_number'])) ? $config['tsrat_number'] : '',
          'TS_JSSCROLL_DIRECTION'         => (!empty($config['ts_jsscroll_direction'])) ? true : false,
          'TS_JSSCROLL_PAUSE'            => (!empty($config['ts_jsscroll_pause'])) ? true : false,
          'TS_JSSCROLL_NAVIGATION'      => (!empty($config['ts_jsscroll_navigation'])) ? true : false,
          'S_TSRAT_ENABLE'               => (!empty($config['tsrat_enable'])) ? true : false,
          'S_TS_JSSCROLL'               => (isset($config['ts_jsscroll'])) ? $config['ts_jsscroll'] : '',
          'S_TS_TICKER'                  => (!empty($config['ts_ticker_enable'])) ? true : false,
        ));
    }
Hum, I am not deleting the original code from index.php orindex_body.html. ( I want the scrolling element on show on index too).

What about this portion of the code?

Code: Select all

//-- mod: Top Stats ---------------------------------------------------------//
	include($phpbb_root_path . 'includes/functions_top_stats.' . $phpEx);
//-- end: Top Stats ---------------------------------------------------------//

Top Stats

Posted: 07 Oct 2012, 13:16
by Stoker
cabalganti wrote:What about this portion of the code?

Code: Select all

    //-- mod: Top Stats ---------------------------------------------------------//
       include($phpbb_root_path . 'includes/functions_top_stats.' . $phpEx);
    //-- end: Top Stats ---------------------------------------------------------//
Its should NOT be in viewforum.php
Only the code I posted.