Logikos
02-01-2006, 07:28 PM
After lurking around sitepoint today, I thought I would create a hack much like they have. "Recently Viewed". The first thing I did is search vB.org to see if it was recently released, or released in the past. I did find a few request for this, but no hack has ever been acually released to the public.
So I started thinking how I can create this hack the best way possiable. The first thing that came into mind is create a new table called "recentlyviewed" with the following information.
'recentlyviewed' Table
userid
The userid of the user viewing the thread
threadid
The threadid of the thead the user is viewing
dateline
The date/time user viewed thread. (TIMENOW)
This means the 1 query will be added on the showthread.php page (per user). Now this method can instantly start filling the "recentlyviewed" table with large boards; Seeing as showthread.php is the mosted used file IMHO. So I thought, lets only keep 5 listing per userid.
Keep only 5 listing in database (per userid)
This would be done using the global.php file...
Scenario:
User has viewed 10 threads (according to the recentlyviewed table). Delete the oldest 5.
Conditions before sql execution:
SQL = count total threads where userid = userid
if (user has more the 5 viewed threads)
{
Delete the oldest threads viewed, keeping the latest 5
}
else
{
exit();
}
Now please note that I havn't even started coding this. I just started thinking about it and wanted to get in on paper, and also hear what a few other coders input before I start. So, if you have a better method, please explain. If not, how can I delete the oldest threads viewed, keeping the latest 5? Thanks everyone! :)
Also, I will publicly release this once this is finished...
So I started thinking how I can create this hack the best way possiable. The first thing that came into mind is create a new table called "recentlyviewed" with the following information.
'recentlyviewed' Table
userid
The userid of the user viewing the thread
threadid
The threadid of the thead the user is viewing
dateline
The date/time user viewed thread. (TIMENOW)
This means the 1 query will be added on the showthread.php page (per user). Now this method can instantly start filling the "recentlyviewed" table with large boards; Seeing as showthread.php is the mosted used file IMHO. So I thought, lets only keep 5 listing per userid.
Keep only 5 listing in database (per userid)
This would be done using the global.php file...
Scenario:
User has viewed 10 threads (according to the recentlyviewed table). Delete the oldest 5.
Conditions before sql execution:
SQL = count total threads where userid = userid
if (user has more the 5 viewed threads)
{
Delete the oldest threads viewed, keeping the latest 5
}
else
{
exit();
}
Now please note that I havn't even started coding this. I just started thinking about it and wanted to get in on paper, and also hear what a few other coders input before I start. So, if you have a better method, please explain. If not, how can I delete the oldest threads viewed, keeping the latest 5? Thanks everyone! :)
Also, I will publicly release this once this is finished...