Top Five

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
Locked
User avatar
alhitary
Registered User
Posts: 868
Joined: Wed Jan 17, 2007 7:51 am
Location: ROY
Name: Basil Taha Alhitary
Contact:

Re: top_five

Post by alhitary »

RMcGirr83 wrote:
I mean i want title of new topics show in the list
:?

The topic title is what is shown.

or

Do you mean you only want it to change if there has been a new topic posted...no matter the date of a reply of that topic?

I'm sorry I'm not completely understanding your request.
Yes the title of topic is shown but i want new topics sorted by latest date
Any new post or replies are excluded ( not shown in the list )
I want only new topics

Ex :
I post 1st topic , it will be shown in the list ( 1st line ) , then when i post 2nd topic , it will be shown uper the 1st topic ( here 1st topic will be in 2nd line and second topic will be in 1st line in the list ).
Now , if someone replied on 1st topic , it will be shown upper the 2nd topic...
I don't want that
I want only new topics shown in the list and any not shown the topics with new replies

I pray to God it is clear :D
User avatar
RMcGirr83
Former Team Member
Posts: 21905
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: top_five

Post by RMcGirr83 »

That was much better. :)

Please try this

OPEN

includes/top_five.php

FIND

Code: Select all

	// we have auths, change the sql query below
	$sql_and = '';
	if (sizeof($forum_array))
	{
		$sql_and = ' AND ' . $db->sql_in_set('p.forum_id', $forum_array, true);
	}

	// grab all posts that meet criteria and auths
	$sql_ary = array(
		'SELECT'	=> 'MAX(p.post_time) as post_time, u.user_id, u.username, u.user_colour, t.topic_title, t.forum_id, t.topic_last_post_id',
		'FROM'		=> array(TOPICS_TABLE => 't', POSTS_TABLE => 'p'),
		'LEFT_JOIN'	=> array(
			array(
				'FROM'	=> array(USERS_TABLE => 'u'),
				'ON'	=> 'p.poster_id = u.user_id',
   			),
		),
		'WHERE'		=> 'p.topic_id = t.topic_id
			   AND p.post_approved = 1
			   AND t.topic_moved_id = 0' . $sql_and,
		'GROUP_BY'	=> 't.topic_id',
		'ORDER_BY'	=> 'post_time DESC',
	);

	$result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), 5);

    while( $row = $db->sql_fetchrow($result) )
    {
   
		$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id']);
REPLACE WITH

Code: Select all

	// we have auths, change the sql query below
	$sql_and = '';
	if (sizeof($forum_array))
	{
		$sql_and = ' AND ' . $db->sql_in_set('t.forum_id', $forum_array, true);
	}

	// grab all posts that meet criteria and auths
	$sql_ary = array(
		'SELECT'	=> 't.topic_title, t.forum_id, t.topic_first_post_id, u.user_id, u.username, u.user_colour',
		'FROM'		=> array(TOPICS_TABLE => 't'),
		'LEFT_JOIN'	=> array(
			array(
				'FROM'	=> array(USERS_TABLE => 'u'),
				'ON'	=> 't.topic_poster = u.user_id',
   			),
		),
		'WHERE'		=> 't.topic_approved = 1
			   AND t.topic_moved_id = 0' . $sql_and,
		'ORDER_BY'	=> 't.topic_time DESC',
	);

	$result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), 5);

    while( $row = $db->sql_fetchrow($result) )
    {
   
		$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['topic_first_post_id'] . '#p' . $row['topic_first_post_id']);
..and see if that works for you.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
rsandr
Registered User
Posts: 39
Joined: Fri Nov 27, 2009 9:47 am
Location: East Lancs, UK
Contact:

Re: top_five

Post by rsandr »

This is a nice mod, thanks to the author.
I have read through every page I promise and have since tweaked a few other things but I have another question.

After the posters name I would like to display FORUM_NAME, is this easily achievable?

I don't need help with layout etc, just how to 'call' it up.

Many thanks.
User avatar
RMcGirr83
Former Team Member
Posts: 21905
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: top_five

Post by RMcGirr83 »

Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
rsandr
Registered User
Posts: 39
Joined: Fri Nov 27, 2009 9:47 am
Location: East Lancs, UK
Contact:

Re: top_five

Post by rsandr »

Thanks, that's very helpful.
rsandr
Registered User
Posts: 39
Joined: Fri Nov 27, 2009 9:47 am
Location: East Lancs, UK
Contact:

Re: top_five

Post by rsandr »

i have separated the topic and the forum name as follows and edited the html file so that the forum name is displayed after the poster name.

Code: Select all

	$template->assign_block_vars('top_five_topic',array(
       		'U_TOPIC' 		=> $view_topic_url,
       		'USERNAME_FULL'   =>  $user->lang['BY'] . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
                'TOPIC_TITLE'    => $topic_title,
                'FORUM_NAME'    => $forum_name . $row['forum_name']));
    }
Please let me know if there are any problems with what i've done.
I don't quite get why I had to add this bit when it doesn't seem necessary with $topic_title

Code: Select all

. $row['forum_name']
What I am struggling with now is how to turn the forum name into a link.

Any further help appreciated.
User avatar
RMcGirr83
Former Team Member
Posts: 21905
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: top_five

Post by RMcGirr83 »

Please post up your entire includes/top_five.php file and I'll take a look.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
rsandr
Registered User
Posts: 39
Joined: Fri Nov 27, 2009 9:47 am
Location: East Lancs, UK
Contact:

Re: top_five

Post by rsandr »

Cheers.

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: top_five.php,v 1.0.5 2009/08/17 06:20:00 EST rmcgirr83 Exp $
* @copyright (c) 2009 Rich McGirr
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
* Include only once.
*/
if (!defined('INCLUDES_TOP_FIVE_PHP'))
{
	define('INCLUDES_TOP_FIVE_PHP', true);
	
	global $auth, $cache, $config, $user, $db, $phpbb_root_path, $phpEx, $template;

    $user->add_lang('mods/top_five');

	// grab auths that allow a user to read a forum
	$forum_array = array_unique(array_keys($auth->acl_getf('!f_read', true)));

	// we have auths, change the sql query below
	$sql_and = '';
	if (sizeof($forum_array))
	{
		$sql_and = ' AND ' . $db->sql_in_set('p.forum_id', $forum_array, true);
	}

	// grab all posts that meet criteria and auths
	$sql_ary = array(
                 'SELECT'   => 'MAX(p.post_time) as post_time, u.user_id, u.username, u.user_colour, t.topic_title, t.forum_id, t.topic_last_post_id, f.forum_name',
		'FROM'		=> array(TOPICS_TABLE => 't', POSTS_TABLE => 'p'),
		'LEFT_JOIN'	=> array(
			array(
				'FROM'	=> array(USERS_TABLE => 'u'),
				'ON'	=> 't.topic_last_poster_id = u.user_id',
   			),
             array(
            'FROM'   => array(FORUMS_TABLE => 'f'),
            'ON'   => 't.forum_id = f.forum_id',
            ),
		),
		'WHERE'		=> 'p.topic_id = t.topic_id
			   AND p.post_approved = 1
			   AND t.topic_moved_id = 0' . $sql_and,
		'GROUP_BY'	=> 't.topic_id',
		'ORDER_BY'	=> 'post_time DESC',
	);

	$result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), 20);

    while( $row = $db->sql_fetchrow($result) )
    {
   
		$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id']);
		$topic_title = censor_text($row['topic_title']);

       	$template->assign_block_vars('top_five_topic',array(
       		'U_TOPIC' 		=> $view_topic_url,
       		'USERNAME_FULL'   =>  $user->lang['BY'] . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
                'TOPIC_TITLE'    => $topic_title,
                'FORUM_NAME'    => $forum_name . $row['forum_name']));
    }

    $db->sql_freeresult($result);

	// an array of user types we dont' bother with
	// could add board founder (USER_FOUNDER) if wanted
	$ignore_users = array(USER_IGNORE, USER_INACTIVE);
	
	// top five posters
	if (($user_posts = $cache->get('_top_five_posters')) === false)
	{
	    $user_posts = array();

		// grab users with most posts
	    $sql = 'SELECT user_id, username, user_colour, user_posts
	       	FROM ' . USERS_TABLE . '
			WHERE ' . $db->sql_in_set('user_type', $ignore_users, true) . '
				AND user_posts <> 0
	       ORDER BY user_posts DESC';
		$result = $db->sql_query_limit($sql, 5);

		while ($row = $db->sql_fetchrow($result))
		{
			$user_posts[$row['user_id']] = array(
				'user_id'		=> $row['user_id'],
                'username'		=> $row['username'],
                'user_colour'	=> $row['user_colour'],
				'user_posts'    => $row['user_posts'],
			);
		}
        $db->sql_freeresult($result);

		// cache this data for 5 minutes, this improves performance
		$cache->put('_top_five_posters', $user_posts, 300);
	 }

	 foreach ($user_posts as $row)
	 {
		$username_string = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);

		$template->assign_block_vars('top_five_active',array(
			'S_SEARCH_ACTION'	=> append_sid("{$phpbb_root_path}search.$phpEx", 'author_id=' . $row['user_id'] . '&sr=posts'),
			'POSTS' 			=> $row['user_posts'],
			'USERNAME_FULL'		=> $username_string)
	   );
    }

    // newest registered users
	if (($newest_users = $cache->get('_top_five_newest_users')) === false)
	{
	    $newest_users = array();

	    // grab most recent registered users
		$sql = 'SELECT user_id, username, user_colour, user_regdate
			FROM ' . USERS_TABLE . '
			WHERE ' . $db->sql_in_set('user_type', $ignore_users, true) . '
				AND user_inactive_reason = 0
			ORDER BY user_regdate DESC';
		$result = $db->sql_query_limit($sql, 5);

		while ($row = $db->sql_fetchrow($result))
		{
			$newest_users[$row['user_id']] = array(
				'user_id'				=> $row['user_id'],
				'username'				=> $row['username'],
     			'user_colour'			=> $row['user_colour'],
                'user_regdate'			=> $row['user_regdate'],
			);
		}
	    $db->sql_freeresult($result);

		// cache this data for 5 minutes, this improves performance
		$cache->put('_top_five_newest_users', $newest_users, 300);
	 }

	 foreach ($newest_users as $row)
	 {
		$username_string = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);

		$template->assign_block_vars('top_five_newest',array(
			'REG_DATE'			=> $user->format_date($row['user_regdate']),
			'USERNAME_FULL'		=> $username_string)
	   );
    }
}
?>
User avatar
RMcGirr83
Former Team Member
Posts: 21905
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: top_five

Post by RMcGirr83 »

Try using this (it's a snippet but you should be able to see where it goes in the file).

Code: Select all

   $result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), 20);

    while( $row = $db->sql_fetchrow($result) )
    {
   
      $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id']);
	  $forum_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']);
      $topic_title = censor_text($row['topic_title']);

          $template->assign_block_vars('top_five_topic',array(
			'U_TOPIC'       => $view_topic_url,
            'USERNAME_FULL'   =>  $user->lang['BY'] . get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
            'TOPIC_TITLE'    => $topic_title,
			'U_FORUM'		=> $forum_url,	
                'FORUM_NAME'    => $row['forum_name']));
    }
then in the html file

Code: Select all

<a href="{top_five_topic.U_FORUM}">{top_five_topic.FORUM_NAME}</a>
See if that is what you are looking for.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
rsandr
Registered User
Posts: 39
Joined: Fri Nov 27, 2009 9:47 am
Location: East Lancs, UK
Contact:

Re: top_five

Post by rsandr »

That's absolutely fantastic fella.
Many thanks.
User avatar
alhitary
Registered User
Posts: 868
Joined: Wed Jan 17, 2007 7:51 am
Location: ROY
Name: Basil Taha Alhitary
Contact:

Re: top_five

Post by alhitary »

dear
i don't want the title of post to be shown all
i want to show only part of the title and the rest is ...
how plz ?
rsandr
Registered User
Posts: 39
Joined: Fri Nov 27, 2009 9:47 am
Location: East Lancs, UK
Contact:

Re: top_five

Post by rsandr »

alhitary wrote:dear
i don't want the title of post to be shown all
i want to show only part of the title and the rest is ...
how plz ?
I don't know on which page but it is in this thread somewhere.

Edit: Is this what you are after?
http://www.phpbb.com/community/viewtopi ... s#p9258325
User avatar
RMcGirr83
Former Team Member
Posts: 21905
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: top_five

Post by RMcGirr83 »

Amazing what one can find if one actually uses the search feature, eh?
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
r9skull
Registered User
Posts: 13
Joined: Sun Feb 07, 2010 11:41 am
Location: Poland
Contact:

Re: top_five

Post by r9skull »

I have a phpbb 3.06 and this mod doesn't work. Screen:
http://i49.tinypic.com/2ex3k79.jpg
How to fix this?
Image
Locked

Return to “[3.0.x] MOD Database Releases”