Creating a Forum: View new posts?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
zeve
Forum Newbie
Posts: 4
Joined: Mon Jan 12, 2009 3:12 pm

Creating a Forum: View new posts?

Post by zeve »

Hey guys,

I have created a forum.

The db structure is like this
1 table of subcategories (ie general, coding, marketplace, etc)
1 table of topics
and 1 table of replies

I want each individual user to be able to hit a "view new posts" button to see posts that they havent seen yet, similar to what we have here on devnetwork.

How can something like this be achieved? What is the best route and method to do something like this?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Creating a Forum: View new posts?

Post by s.dot »

PHPBB uses cookies for this.
Probably something along the lines of storing post ID's that have been viewed, then querying for posts that are new and not in this list from the cookie.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
zeve
Forum Newbie
Posts: 4
Joined: Mon Jan 12, 2009 3:12 pm

Re: Creating a Forum: View new posts?

Post by zeve »

Do i need to create an array in the cookie?

Isnt there a limit on how big a cookie can be? If a user views 100 posts, wont it start being excessive?
webaddict
Forum Commoner
Posts: 60
Joined: Wed Mar 14, 2007 6:55 am
Location: The Netherlands

Re: Creating a Forum: View new posts?

Post by webaddict »

zeve wrote:Isnt there a limit on how big a cookie can be? If a user views 100 posts, wont it start being excessive?
There is a limit, although I'm not certain what the limit is, exactly. I know that some forums will treat every post that has a reply which is older than two weeks as "read" by default, and only classify the others as unread. Although it's not exactly "read", this will assure some performance. Other than that, it's just the question of where you store the info: in the database or in a cookie. You might want to do both: if the cookie is stale (too old) or not present, you can generate a new list of unread topics. Let me know how this turns out, as I might have to implement this myself soon, too.
zeve
Forum Newbie
Posts: 4
Joined: Mon Jan 12, 2009 3:12 pm

Re: Creating a Forum: View new posts?

Post by zeve »

I've thought of an issue with using cookies...

What if they use a different computer???
Theory?
Forum Contributor
Posts: 138
Joined: Wed Apr 11, 2007 10:43 am

Re: Creating a Forum: View new posts?

Post by Theory? »

Then store it in the session and persist the session to the DB after each visit.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Creating a Forum: View new posts?

Post by josh »

You only need to track viewed forums during the session. After the session ends you prune out 1,000s of forums you don't have to check, since their last_posted_in timestamp < session_began_timestamp
Post Reply