phpBB3: How to display number of posts since last visit?

2014-02-20 phpBB

You won’t find this feature in the default phpBB3 installation. To display number of new posts since last visit you just have to edit small piece of 3 files:



and try to find line:

$tz = ($user->data['user_id'] != ANONYMOUS) ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone']));

After this line add:

$sql = "SELECT COUNT(post_id) as total
        FROM " . POSTS_TABLE . "
        WHERE post_time >= " . $user->data['user_lastvisit'] . "
        AND poster_id != " . $user->data['user_id'];

        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $total = $row['total'];

Note that line you need to look for may look a little bit different. In the same file look for:

'U_SEARCH_NEW' => append_sid("{$phpbb_root_path}search.$phpEx", 'search_id=newposts'),

After this line add:

'TOTAL' => $total,

Save file and open:


Search for:

<a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a>

Replace this with:

<a href="{U_SEARCH_NEW}">{L_SEARCH_NEW} ({TOTAL})</a>

That’s all. Clean cache if needed and check how it works.

Do NOT follow this link or you will be banned from the site!