Jump to content


Photo

Unread posts


  • This topic is locked This topic is locked
10 replies to this topic

#1 Lux01

Lux01

    Young Padawan

  • Members
  • Pip
  • 5 posts
  • Location:Lancashire, England

Posted 03 August 2006 - 11:42 AM

Hey,

I was wondering if anyone could help me understand how one would go about coding something similar to the Unread posts feature which is in forum software. I think it might have something to do with sessions but I'm not sure. Can anyone help?

Thanks.

#2 Erik Bernskiold

Erik Bernskiold

    Jedi In Training

  • Members
  • PipPip
  • 422 posts
  • Gender:Male
  • Location:Gothenburg, Sweden
  • Interests:I love to do booth Web Design and Photography. Nothing beats a nice day out in the nature with the camera gear, getting loads of nice photos. I have been playing the flute for 6 years now and I love it, and I am playing the pipe organ as well. I also like to teach other people the in and outs of software such as the CS3 suite from Adobe.

Posted 03 August 2006 - 12:14 PM

I would suspect it plants a cookie on the users machine when you exit your browser or log out, (or a session is exited) and then when you come to the site next time it sees when you were last online and displays another mark in front of the posts that has been made since.

However that's just what I think and I am not very experienced in PHP yet...

#3 Matthew.

Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 03 August 2006 - 12:15 PM

This is my nightware question because there are many ways, half of them drag your page by quite a bit if there are many entries.


That way is to make a new table called whatever you want, and everytime a topic is read, enter the username, timestamp, and topic id. Then we check the last reply in the topic against the entry (or lack of) and if the timesamp of the last read entry is less than the last reply, then you produce an unread message symbol.

You can see the problemim sure, that is after a while, that becomes one hell of a query. So what i would do is use an array and serialize it into the database with the last read time and the topic id.


I have written a tutorial or serialize and how to use it here:
http://www.pixel2lif...showtopic=21892

Good luck :)

As for your idea of sessions, well, they could be incorporated i guess, but if you want cross computer "rememberage" of whats read and unread it untimately has to be stored in some type of database.

edit: to add on what erik said, that is as i mentioned another way to do it, and it would cut down queries but you would still have to go through every post in the database and check it against the time. Also you have the problem of deciding the time to store. How long after inactivity? update the time after you reload the page? no because then no topics would be unread :P but that is not ruling it out. I think a certain *sheep* bboard called chipmunk something or rather does it that way, its not succesfull lol

It's one of my pain in the ass questions that i dont like lol

Edited by .Matt, 03 August 2006 - 12:20 PM.


#4 Erik Bernskiold

Erik Bernskiold

    Jedi In Training

  • Members
  • PipPip
  • 422 posts
  • Gender:Male
  • Location:Gothenburg, Sweden
  • Interests:I love to do booth Web Design and Photography. Nothing beats a nice day out in the nature with the camera gear, getting loads of nice photos. I have been playing the flute for 6 years now and I love it, and I am playing the pipe organ as well. I also like to teach other people the in and outs of software such as the CS3 suite from Adobe.

Posted 03 August 2006 - 12:17 PM

I suspect .Matt (as always) gives you more accurate and better replies than I do, thus, I was more or less leaving it up to him with my opinion.

#5 Lux01

Lux01

    Young Padawan

  • Members
  • Pip
  • 5 posts
  • Location:Lancashire, England

Posted 03 August 2006 - 12:17 PM

Thanks for your fast replies. To be honest I was hoping someone would provide an answer which doesn't include Sessions because I have no experience what so ever in them :P.

I shall take a look at your guide right now .Matt.

Thanks again for your replies.

#6 eric81

eric81

    Young Padawan

  • Members
  • Pip
  • 258 posts
  • Gender:Male

Posted 03 August 2006 - 02:36 PM

Cookies have a length limit... however you could store a timestamp in one cookie and the articles viewed in another cookie (by id of course). When the cookie reaches a certain limit dump the cookie into a database. I dunno how well that would work. But in theory it'd cut down on the update queries to the database... Feel free to pick it apart as the only reason I mentioned it was I racked my brain for an alternative to what Matt said.

#7 danieldaniel

danieldaniel

    Young Padawan

  • Members
  • Pip
  • 75 posts
  • Gender:Male
  • Location:Columbus, Ohio
  • Interests:Skateboarding, Macs, BMX, Cocoa, PHP, CSS etc.

Posted 03 August 2006 - 03:16 PM

Sessions really aren't hard at all, and that's really the only way I could think of doing it. I think large forums like VBulletin and IPB have forums where you can ask the creators questions, you may want to find those and ask them how they did it.

#8 Matthew.

Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 03 August 2006 - 03:21 PM

Sorry i have to ask....

how do you intend to use sessions without coming back to dumping it in a database? and if you were including a database anyway wouldnt it be easier to use cookies? since they dont go after you close the browser?

Not that i suggest the use of either cookies or sessions :P

#9 Hayden

Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 717 posts
  • Gender:Male
  • Location:Texas

Posted 03 August 2006 - 03:53 PM

Sessions really aren't hard at all, and that's really the only way I could think of doing it. I think large forums like VBulletin and IPB have forums where you can ask the creators questions, you may want to find those and ask them how they did it.


I believe most large applications like what Invision Power creates and others, typically use a blending of Sessions AND cookies, right? :D :P

#10 Matthew.

Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 03 August 2006 - 04:05 PM

Sessions really aren't hard at all, and that's really the only way I could think of doing it. I think large forums like VBulletin and IPB have forums where you can ask the creators questions, you may want to find those and ask them how they did it.


I believe most large applications like what Invision Power creates and others, typically use a blending of Sessions AND cookies, right? :) :P



With all developers, use sessions when appropriate, use cookies when appropriate :D

#11 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 03 August 2006 - 04:51 PM

This question has been asked before, please use the forum search.

http://www.pixel2lif...p...1&hl=unread




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users