1

Topic: Detecting new posts?

Does anybody know what the quickest way is to detect if there are any new posts via header.php. I don't need to know how many there are or see them, just detect if any exist.

Re: Detecting new posts?

$db->result($db->query('SELECT count(id) from '.$db->prefix.'forums where last_post > '.$pun_user['last_visit']));

if its more than 0 theres new posts you'll need to check for is_guest though as it will be more than 0, if it is 0 then there are no new posts, there might be a better way to do it but i guess you can change it later smile

3

Re: Detecting new posts?

Thanks. If you are wondering what the point is, somebody asked me to get rid of the "New posts since last visit" and "Mark as read" links when there were no new posts. Actually using count could be quite good, the "New since last visit" link could be changed to "There are x new posts".

Re: Detecting new posts?

well that number is the number of forums with new posts, i did that instead of plain number of topics with new posts as the forums table is smaller, therefore i assuming this would be faster

5

Re: Detecting new posts?

Thats fine, the main thing was to get rid of pointless links and save people the bother of clicking "Show new posts" only to be told to get stuffed. I should have specified that the users in question can't see the board so they come across the new posts link before they get to the post indicators.