PDA

View Full Version : Recently Viewed Threads


Logikos
11 Feb 2006, 22:44
https://www.vbulletin.org/forum/ (http://www.vbhackers.com)
Recently Viewed Threads

www.vBHackers.com (http://www.vBHackers.com)

What this does
This will show each user a list of Recently Viewed Threads. The idea came from www.SitePoint.com (http://www.SitePoint.com). I found myself using it alot when I came back to the site to check up on some threads I forgot about, or just couldn't find. AJAX enabled - (quick thread title edit and open/close works!)

This was coded to be placed on the forumhome, though you can edit to your needs if you know what your doing.

How this plugin works
The concept of this plugin is simple. When a user clicks on a thread, it will log the user and thread info in the database. The thread will then be marked as viewed using a conditional timestamp comparison. In lamens terms this means that when a user views a thread, it will log the time the thread was viewed. It will not relog the thread information if the user views the same thread within a certain amount of wait time. (Admin CP setting). Default is 5 minutes.

Descriptive Example
LiveWire clicks on a thread titled 'New Hack Posted'. 1 small query is performed to see if I have recently viewed this thread yet.

If I have viewed this thread already, it will check and see when I viewed it. If it was longer then 5 minutes ago, then it will add the new information using 1 more query.

If I have never viewed this thread before, then it will insert it into the database using 1 query.

To do list...
Time to install: 2 minutes or less
Queries to run: 1 (Installer Controlled)
File Mods: 0
Templates to edit: 1 (forumhome)
Templates to add: 1 (Installer Controlled 'forumhome_recentbit')
New Phrases: 0
New Plugins: 2Click It For Support!
Install This Product
(http://www.vbulletin.org/forum/vborg_miscactions.php?do=installhack&threadid=107739)

Important Note
This product of mine is marked as beta as I'm still working on some code for future releases. vBCron to clean up Database will be released soon as an addon in the below post.

Product History
Sun, Feb 12 2006 - Forumhome Recent Table is can be collapsed
Sun, Feb 12 2006 - Added plugins (The two plugins didn't export for some reason)
Sat, Feb 11 2006 - Beta Released


Help & Support
Before asking for support Please make sure you have done all necessary changes! If you still need support please post a reply here and double check that you have clicked the Install Button (http://www.vbulletin.org/forum/vborg_miscactions.php?do=installhack&threadid=107739).

Please post bugs and errors here. Hope you like, feedback welcomed! :)

Logikos
11 Feb 2006, 22:45
-Post Reserved-

-=Sniper=-
11 Feb 2006, 23:32
nice, will be using it for sure :)

FleaBag
12 Feb 2006, 00:23
The recently viewed threads don't show up but the shell of the template does. Nothing else seems to work incorrectly.

Logikos
12 Feb 2006, 06:40
Recently Viewed Threads
Version 1.1 Beta

There was a strange bug on my end when exporting the product. It didn't add the plugins to the product, anyway I fixed the little buggy for everyone.

Upgrade
For those of you who installed the 1.0 Beta version and wish to upgrade to v1.1 Beta, please import product-recentlyviewed.xml via AdminCP -> Plugin System -> Manage Products And make sure Allow Overwrite is set to YES

.Tim
12 Feb 2006, 07:36
The recently viewed threads don't show up but the shell of the template does. Nothing else seems to work incorrectly.

Same here. No threads show up for me. :(

Logikos
12 Feb 2006, 08:21
Read the post directly above you.

.Tim
12 Feb 2006, 09:24
I know, I've done that.

.Tim
12 Feb 2006, 09:27
Hmm, I re-uploaded it and it worked this time. Odd.

The Realist
12 Feb 2006, 10:06
Dont work for me its blank.

Installed the new version from scratch as well.

bashy
12 Feb 2006, 10:34
Working oK for me :)

Those that think it aint...go view a thread then goo look..(refresh just in case)

Could you please make this collapseable?
Nice hack btw

The Realist
12 Feb 2006, 10:44
looked at a thread and still nowt?

Akagi
12 Feb 2006, 10:57
It'll be interesting if you could implement this into the UserCP like IPB2

bashy
12 Feb 2006, 11:39
Very strange...Mine worked 1st time..
I then moved the hack further up the template and still
works 100%....I dont know what to suggest..

Have you turned it on in your admincp?

looked at a thread and still nowt?

KMxRetro
12 Feb 2006, 11:58
Installed - shows "Recently Viewed Threads" even when there are none to show...very shabby. Also, turns the Thread count in the "Threads/Posts/Users" at the top of my page to however many recently viewed threads there are.

Threads: 1, Posts: 2,303, Members, 2,700 for example.

Oh, and there's no AJAX to be found.

Uninstalled.

Snake
12 Feb 2006, 12:22
Thank you, I'm gonna install this... :D

bashy
12 Feb 2006, 12:30
Installed - shows "Recently Viewed Threads" even when there are none to show...very shabby. Also, turns the Thread count in the "Threads/Posts/Users" at the top of my page to however many recently viewed threads there are.

Threads: 1, Posts: 2,303, Members, 2,700 for example.

Oh, and there's no AJAX to be found.

Uninstalled.



Hi

I beg to differ, mine is working 100%
please see www.bashys-place.com or to skip the brill intro use www.bashys-place.com/forums i am afraid you will need to register by the looks of it
as its a members only hack, wich is a shame as guest could make use of this as well

Fancy inplementing this LiveWire, Guest as well?

The Realist
12 Feb 2006, 12:46
Uninstalled.

Sorry.

FleaBag
12 Feb 2006, 15:57
Working for me! Thanks for the update LiveWire. To call someone's hack shabby is a bit lame! I think it's top notch. As far as moving to the UserCP is concerned, a little fiddling with the plugins could probably achieve this. I'm gonna try to get it working in CMPS. :)

Logikos
12 Feb 2006, 20:51
I've just downloaded and installed this hack on a fresh vBulletin 3.5.3 install and it works perfect. Ajax is working also (Here is another screenshot of me using it) You have to remember to save your settings in the admincp before this to work. The active staus is turned off by default.

vBulletin Options -> Recently Viewed Threads -> Recently Viewed Active -> Set to Yes

bashy
12 Feb 2006, 20:55
Whats the text box with Test in it in your image Livewire?

Logikos
12 Feb 2006, 21:16
This post marks a newer version
v1.2 Beta Released

The forumhome Recent table can now be collapsed. The Main Zip file has been updated. For those who wish to upgrade there templates, please follow these Template Instructions:

Template Forumhome:
------------------------------
Find:

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center" id="threadslist">
<tr>
<td colspan="6" class="tcat">Recently Viewed Threads</td>
</tr>
<tr>
<td class="thead" colspan="2">&nbsp;</td>
<td class="thead" width="100%">$vbphrase[thread] / $vbphrase[thread_starter]</td>
<td class="thead" width="150" align="center" nowrap="nowrap"><span style="white-space:nowrap">$vbphrase[last_post]</span></td>
<td class="thead" align="center" nowrap="nowrap"><span style="white-space:nowrap">$vbphrase[replies]</span></td>
<td class="thead" align="center" nowrap="nowrap"><span style="white-space:nowrap">$vbphrase[views]</span></td>
</tr>

$recentbits
</table>



Replace With

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center" id="threadslist">
<tbody>
<tr>
<td colspan="6" class="tcat">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_recent')"><img id="collapseimg_forumhome_recent" src="$stylevar[imgdir_button]/collapse_tcat$vbcollapse[collapseimg_forumhome_recent].gif" alt="" border="0" /></a>
Recently Viewed Threads
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_recent" style="$vbcollapse[collapseobj_forumhome_recent]">
<tr>
<td class="thead" colspan="2">&nbsp;</td>
<td class="thead" width="100%">$vbphrase[thread] / $vbphrase[thread_starter]</td>
<td class="thead" width="150" align="center" nowrap="nowrap"><span style="white-space:nowrap">$vbphrase[last_post]</span></td>
<td class="thead" align="center" nowrap="nowrap"><span style="white-space:nowrap">$vbphrase[replies]</span></td>
<td class="thead" align="center" nowrap="nowrap"><span style="white-space:nowrap">$vbphrase[views]</span></td>
</tr>
$recentbits
</tbody>
</table>

Logikos
12 Feb 2006, 21:17
Whats the text box with Test in it in your image Livewire?

That is a title of a thread. You can use AJAX to edit the titles and close threads.

bashy
12 Feb 2006, 21:19
Great m8, thanks for doing this :)
Works well

Bison
13 Feb 2006, 01:00
Good work! *Installed*

sonicdriven
13 Feb 2006, 22:33
I was going to try and create this hack myslef but why when yours works perfect! Install was smooth as can be! I'm going to try and extend this so it can be used on the pages created with the Drupal Plugin..

Awesome Job, not shabby at all, a much needed mod for VB IMO.

dxguru
15 Feb 2006, 15:35
Could this be done so that it shows on the users MEMBERPROFILE page?
ie when I look at someone elses profile I see the threads they have recently viewed.

bashy
16 Feb 2006, 17:27
Hi

It appears that i am now getting this DB error whilst using your hack

Database error in vBulletin 3.5.3:

Invalid SQL:

SELECT post.pagetext AS preview,
thread.threadid, thread.title AS threadtitle, lastpost, forumid, pollid, open, replycount, postusername, postuserid, lastposter,
thread.dateline, views, thread.iconid AS threadiconid, notes, thread.visible


FROM thread AS thread

LEFT JOIN recentlyviewed AS recentlyviewed ON(recentlyviewed.threadid = thread.threadid)
LEFT JOIN post AS post ON(post.postid = thread.firstpostid)
WHERE thread.threadid IN(132,1550,1584,1580,1585,1573,1586,1587,1588,1381,1589,1559,1590,1591,1579,92, 1594,1595,1597,1562,1596,1599,1600,1565,1602,1603,1577,1605,1608,1623,1625,1624, 1627,1628,1629,1622,1630,1643,1645,1644,1641,1647,942,362,509,1581,1606,1648,134 5,1620,1089,1649,130,1651,1650,1505,1658,1668,1666,1413,1667,1660,1663,1669,554, 993,1384,1670,1672,1673,1390,1635,1677,1675,1676)
ORDER BY recentlyviewed.dateline DESC
LIMIT 5;

MySQL Error : The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay Error Number : 1104
Date : Thursday, February 16th 2006 @ 02:11:15 PM
Script : http://www.bashys-place.com/forums/
Referrer :


Please advise?

Logikos
16 Feb 2006, 19:02
Bashy. Log into the Admincp and go to Execute SQL Query and run this query:


DELETE FROM recentlyviewed
WHERE dateline < (1140115611 - 3600)

This should fix it for a couple of days. When I get home I'll create a maintance script. :)

bashy
16 Feb 2006, 19:09
Ok m8 thanks for that....
I take it without a main fix i will get the issue again, if ya not done the main fix by then do i run that again if i get the same issue?

bashy
16 Feb 2006, 19:11
All seems ok again :)
Cheers for the quick response an all that :)

bashy
19 Feb 2006, 20:44
Just had this error

Database error in vBulletin 3.5.3:

Invalid SQL:

SELECT post.pagetext AS preview,
thread.threadid, thread.title AS threadtitle, lastpost, forumid, pollid, open, replycount, postusername, postuserid, lastposter,
thread.dateline, views, thread.iconid AS threadiconid, notes, thread.visible


FROM thread AS thread

LEFT JOIN recentlyviewed AS recentlyviewed ON(recentlyviewed.threadid = thread.threadid)
LEFT JOIN post AS post ON(post.postid = thread.firstpostid)
WHERE thread.threadid IN(1701,1699,1698,1697,1693,1692,1691,1687,1703,1704,1705,1706,1708,1707,1712,17 14,194,1732,1103,1729,1718,1725,1717,1736,1051,1741,1647,1625,1346,1579,1688,174 2,1743,1744,184,1670,1754,1753,1758,1759,1577,1757,1546,1391,1760,1761,1762,1764 ,1766,1765,1749,1747,1748,1755,1767,1768,1769,1770,1771,1773,1774,1775,1776,1751 ,1678,1657,1640,1611,1607,1561,1540,1528,1777,1778,1779,132,1781,1782,1783,1784, 1785,1786,1787,1788,1789,1790,1791,1792,1685,1715,1772,1816,1621)
ORDER BY recentlyviewed.dateline DESC
LIMIT 5;

MySQL Error : The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay Error Number : 1104
Date : Sunday, February 19th 2006 @ 08:35:01 PM
Script : http://www.bashys-place.com/forums/
Referrer : http://www.bashys-place.com/forums/


I tried to run that sql ya gave me but didnt work this time...
Please advise as i have to keep this turned off now :(

Wongod
15 Mar 2006, 10:25
Is this hack working?

thanh
30 Mar 2006, 20:52
me too

I had the errrors

Database error in vBulletin 3.5.4:

Invalid SQL:

SELECT post.pagetext AS preview,
thread.threadid, thread.title AS threadtitle, lastpost, forumid, pollid, open, replycount, postusername, postuserid, lastposter,
thread.dateline, views, thread.iconid AS threadiconid, notes, thread.visible


FROM thread AS thread

LEFT JOIN recentlyviewed AS recentlyviewed ON(recentlyviewed.threadid = thread.threadid)
LEFT JOIN post AS post ON(post.postid = thread.firstpostid)
WHERE thread.threadid IN(4,5,1,2,3,15,19,8,22,23,28,29,11,34,18,24,25,20,40,42,57,59,60,62,31,64,65,35 ,66,6,7,67,41,73,63,72,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92, 93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,71,111,115,117,127,157,134, 181,156,120,186,141,159,197,234,217,216,187,237,196,192,243,211,244,215,133,212, 246,158,268,270,272,274,276,277,278,279,280,281,282,283,284,285,286,287,289,290, 291,292,294,295,296,298,299,300,301,302,303,68,304,307,308,309,310,312,313,314,3 15,316,317,318,320,321,322,323,324,325,326,327,328,180,330,152,331,333,221,335,3 36,337,188,338,341,342,347,340,359,384,379,386,155,385,362,344,390,391,358,396,4 15,441,458,463,436,474,476,429,269,461,484,487,493,488,491,502,509,511,512,513,5 14,515,516,517,519,521,522,523,524,504,424,496,492,154,421,537,531,470,420,560,5 58,564,477,466,426,542,430,494,475,561,566,520,568,604,596,574,600,618,615,614,6 23,624,585,619,622,598,563,577,261,645,423,706,670,757,756,866,937,802,808,841,6 92,960,904,829,1030,1014,1029,1034,1046,377,1036,1044,1033,1018,375,1022,1051,20 6,401,409,367,378,387,13,453,951,1143,1217,1219,1149,1195,1042,1272,1275,1305,63 2,275,241,675,1658,373,1303)
ORDER BY recentlyviewed.dateline DESC
LIMIT 5;

MySQL Error : Got error 28 from table handler
Error Number : 1030
Date : Thursday, March 30th 2006 @ 03:30:52 PM
Script : http://xxxxxxxxxxxxxx/forums/index.php
Referrer : http://xxxxxxxxxx/forums/showthread.php?t=1679
IP Address : xxxxxxxxxxxxxx
Username : admin
Classname : vb_database

thanh
30 Mar 2006, 21:00
@LiveWire

When run
DELETE FROM recentlyviewed
WHERE dateline < (1140115611 - 3600)

The member access forum OK w/o any error but when iam, the administrator loggin in the error still apear :(

thanh
30 Mar 2006, 21:02
AHA, when i'm trying TRUNCATE TABLE `recentlyviewed`
all become the normal now:)

xspazx
03 Apr 2006, 23:10
The hook for this plugin made my forums stats say threads: 5. Maybe you should update that?. I wont click uninstall in hopes that you do fix the slight bug. But it's going to be disabled on my site for now. Thanks.

Logikos
04 Apr 2006, 04:33
I'll be updating this in the next day or so, as I need to fix it for my site. ;)

Wongod
24 Apr 2006, 19:00
Hi LiveWire, any progress? This seems like a great feature.

FleaBag
23 May 2006, 07:17
I get the issue where it says I have 5 threads too. Also, recently this seems to slow down my forumhome loading. Normally <1 second to over a minute. I had to disable even with it only showing 3 threads updating every 30 minutes. Hope you know about this issue and how to fix. :D