The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Recently Viewed (Hack in Progress)
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
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: Code:
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(); } Also, I will publicly release this once this is finished... |
#2
|
||||
|
||||
I am a bit dense today. Where is this meant to show? Does it show recently viewed posts by anyone or does it show the user the posts they recently viewed?
|
#3
|
|||
|
|||
This will show the latest 5 threads (Recently Viewed) per logged in user. This can be shown anywhere one would want really. I will code the public version so its shown on the forumhome page. My personal version will be shown on my cutom portal I'm creating.
I should also note that even though the Recently Viewed table only has 3 rows, I will be able to get the rest of the information using JOINs in the SQL. In case anyone was wondering... |
#4
|
||||
|
||||
Gotcha. I think if I were doing this, I would try to hook into how vbulletin is recording what threads the user has viewed. It tracks them already by user for the getnew to work properly. So, obviously, the info about the threads viewed is stored somewhere. It's just a matter of finding it and pulling it.
|
#5
|
|||
|
|||
yea, though how vBulletin determins which post have been read, is beyond me. I don't think I will beable to hook into there method though. I can't seem to understand/find how they record which post have been read/unread. I would guess its a combination of the post dateline, vistlog, and users last activity. I just don't see a table that would keep track of this all..
|
#6
|
||||
|
||||
From what I'm seeing, it looks like it's in a cookie.
in showthread.php, you'll see, Code:
$threadview = intval(fetch_bbarray_cookie('thread_lastview', $thread['threadid'])); Code:
if ($displayed_dateline <= $threadview) { $updatethreadcookie = true; } |
#7
|
|||
|
|||
Adding to the table could be done with a shutdown query.
I wouldn't do any cleaning on pageloads. Better create a scheduled task for that. Clean the table by either maximum X rows/user, or by dateline. |
#8
|
|||
|
|||
I was thinking what Marco said. a vBcron every X mins. The thing that stoped me was how can I clean the table out per userid? Wouldn't be able to use WHERE userid = $vbulletin->userinfo['userid'] since its running as a cron...
I would have to get every userid from the users table and during the while statement I could clean up the table, but that seems like alot of work for a cron right? |
#9
|
|||
|
|||
A lot of cronjobs perform actions on all users. All it would probably take is a single wellformed SQL-statement.
Cleaning up once a day would be enough i think, maybe once an hour. |
#10
|
|||
|
|||
Thanks Marco, I'll prolly end up doing it that way and will release to the public when finished.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|