Jump to content

New Posts/No new Posts Script


Nick G

Recommended Posts

Hi everyone, I am new (not to PHP) but to this site.

What I need help on and have been trying to figure out, is this:

I'm creating a forum, it works and is coming along nicely. But what I want to know how to do is to create a system that will check to see what threads the user has seen and which ones he/she hasn't. AND if there is a new post in the thread it will show an icon that says (basically) New Post/Thread(s) or if it hasn't been viewed an icon that just says No New Posts/Threads. And once you do view that new thread or post, the icon changes to the viewed icon. If you need an idea on what I mean by this, look at pretty much any popular forum script (my main one is PHPbb).

Example: http://www.phpbb.com/phpBB/

If there is a new post(s) or new thread(s) in a topic/category it shows a circle with like an orange piece of paper in it, if there are no new posts or threads then it just shows a circle with plain piece of paper in it.

There is even one on this forum (On the Forum Home, New Post, No New Post)

I've searched and searched for help or a tutorial on this but no luck.  Any help would be GREATLY appreciated.
Link to comment
Share on other sites

Okay this is what I did for mine, but I havent implemented yet because im to lazy but it works, first you make a new mysql table, lets say `forum_new`, add all the fields like the username, topic id, forum id, and whatever else you want. Okay now thats all done, on the listing of the topics or forums for that matter is when your listing them check each one to see if itsnew or not. Now thats all done when a user is viewing the new topic you make a script all the way at the bottom and you make it delete new one. This should work, if you wanna get more technical about make a thread id row on your table.
Link to comment
Share on other sites

the easiest method woul dbe to use a cookie that stores a delimited string of all the threads the users has visited. simply explode that string and use array_keys() like so:

[code]

$ids = explode('|',$_COOKIE['threads']);

if (array_keys($ids, $viewing_thread_id))
{
// seen it.
}
else
{
//mark New
}
[/code]

this board probably uses something similar. If you choose not to have cookies then perhaps you could implement the same process in a database table.
Link to comment
Share on other sites

[quote author=ToonMariner link=topic=120957.msg496758#msg496758 date=1167911159]
the easiest method woul dbe to use a cookie that stores a delimited string of all the threads the users has visited. simply explode that string and use array_keys() like so:

[code]

$ids = explode('|',$_COOKIE['threads']);

if (array_keys($ids, $viewing_thread_id))
{
// seen it.
}
else
{
//mark New
}
[/code]

this board probably uses something similar. If you choose not to have cookies then perhaps you could implement the same process in a database table.
[/quote]
nah this board doesnt use cookies, or i think any board at that matter uses cookies, it uses mysql like the other boards. my explanation is all you need to achieve this.
Link to comment
Share on other sites

Well, I do like the cookie idea more cause I don't want to have to take up a bunch of space in my MySQL for forums_viewed.  But I also don't know whether or not Cookies would be good, cause some people turn cookies off and my host may very well have them disabled as well (I also have not used cookies very much).  A little more insight to both of your scripts would be great.
Link to comment
Share on other sites

What you could do, ive seen this on some forums, is put time for another field in `forum_new` and make each page check if its been over a certain period of time that the person hasnt looked at it and make it delete it.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.