Firefox PHP

About Posts (new, most read, etc.)

Posted by clintcan 
About Posts (new, most read, etc.)
May 06, 2007 09:50PM
Hi guys,

I know there is a function to call to get recent messages, but I'm not sure if this function is used for the question below...

Just a quick question. How do you get the number of new posts since the user logged in?

Also, how do you get the most read posts? I'm still a bit new with all the integration stuff.

Thanks!
Re: About Posts (new, most read, etc.)
May 06, 2007 11:10PM
Check out the new_count module, which does do some counting on new messages.

The most read posts would need a custom query on the database, since there's nothing like that in the core distro. You have to ask yourself what you mean with most read. Is that over a limited time frame or is it an all time high? And if it's something that is to be used as some hot topics system, wouldn't you include the post count as well? About every admin has his own ideas obout these kinds of statistics, so it's hard to tell you exactly what type of query you would need.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: About Posts (new, most read, etc.)
May 08, 2007 11:11AM
Hi clintcan,

Quote
clintcan
Also, how do you get the most read posts?

Search Most Read Module (5.1 and 5.2 ready)

Regards
Oliver


Using Phorum since 7/2000: forum.langzeittest.de (actual version 5.2.23)
Modules "Made in Germany" for version 5.2: Author_as_Sender, CarCost, Close_Topic, Conceal_Message_Timestamp,
Format_Email, Index_Structure, Mailing_List, Pervasive_Forum, Spritmonitor, Terms_of_Service and German_Language_Files_Package.
Re: About Posts (new, most read, etc.)
May 08, 2007 05:53PM
Thanks a lot guys,

I do have an additional question if you don't mind. How about getting new messages (posts), since last logged in, not just the count? Is there a module for this I can look into?

I suspect I will use phorum_db_get_recent_messages partly, with the count based on what I when the user logged in last am I correct on this?

Again, thank you very much for answering!
Re: About Posts (new, most read, etc.)
May 08, 2007 08:05PM
You'd first have to keep track of the time at which the user logged in the previous time. IMO, this can be done with saving something like time_login1 and time_login2, where time_login1 is the login time for the active session and time_login2 the login time for the previous session. When the user logs in, time_login1 would be stored in time_login2 and time_login1 would be set to the current time. This data can be saved in a custom profile field (e.g. by using an array or a string with "<time1>,<time2>").

After this is taken care of, you have the last login time available. From then on, it's easy to do a count of the new messages since last login. Better not use the phorum_db_get_recent_messages(), since that will retrieve all data for the messages. Instead write a function that does something that looks like "SELECT count(*) from {$PHORUM["message_table"]} WHERE datestamp > $thelastlogintime" (from the top of my head, but I asume the direction is clear).


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login