1

Topic: Marking topics as read

Just wanting to have a quick brainpick on the basic idea. smile The existing mod looks somewhat overly complicated, so just wondering if there is an easier was to go about it.

The basic idea, (and very sketchy at the moment), is literally just checking the db topics table for the last_post time entry and comparing to the users table last_visit entry and creating a topic id's array from there, entering it into a new column in the user table, then comparing against those topic id's in the index/viewforum scripts. Is that general theory sound?

Would entering the id's into the new users table column as a comma separated list, and then using explode to create an array from those id's and using in_array when in index/viewforum viewing be the best way to go about it?

As I mentioned, this idea has only had minimal brain time at the moment, so may well be completely flawed. big_smile


Cheers,

Matt

Re: Marking topics as read

That's essentially what the existing modification does wink
There's a database column added to users. It stores a serialized array of topic ids/view times. It is added to when you view a topic that has a last posted time greater than your last visit time.
On index.php, all of the topics since your last visit are fetched and compared to the data from your new column. Any topics which aren't listed in the serialized array or which have been posted in since the time you last viewed the topic are considered new.
On viewforum.php, as you go through the loop each topic is checked against the array.

3

Re: Marking topics as read

From looking at the other code, it seems to be far more 'extravagant' than it has to be, however, or is my view too simplistic? big_smile I believe it also fetches the post id's as well as just, (or rather than)?, the topic id's? Is there any valid reason for serialising the id's before placing into the db as in the existing mod, btw?

I'll be honest in that I haven't looked at the existing mod indepth, but from the cursory glance I've had, it would appear possible to do the same with approximately half the code?

4

Re: Marking topics as read

Btw, I'll just add, the reason I'm trying not to study the existing mod properly is so that I don't sway my train of thought by looking at how, specifically, someone else has done it. big_smile

Re: Marking topics as read

MattF wrote:

From looking at the other code, it seems to be far more 'extravagant' than it has to be, however, or is my view too simplistic? big_smile

It also allows you to mark an entire forum as read, other than that it doesn't seem to extravagant to me.

MattF wrote:

I believe it also fetches the post id's as well as just, (or rather than)?, the topic id's?

Nope

MattF wrote:

Is there any valid reason for serialising the id's before placing into the db as in the existing mod, btw?

Because you can unserialize it when you take it out of the database and keep the array pairing of topic IDs to last viewed times.

MattF wrote:

I'll be honest in that I haven't looked at the existing mod indepth, but from the cursory glance I've had, it would appear possible to do the same with approximately half the code?

I haven't looked at the code for it in a while, but I doubt it tongue

6

Re: Marking topics as read

I'll ditch this idea before I start then. big_smile Better to avoid another one of those 'whatever possessed me to try' sessions while I have the chance. big_smile Cheers Smartys. smile