Version: 1.00, by mvigod
Developer Last Online: Dec 2014
Version: 2.2.x
Rating:
Released: 03-01-2002
Last Update: Never
Installs: 19
No support by the author.
This is my first "released" hack so I can give something back for all the cool hacks I found here.
This one is fairly simple. What it does is put a small icon next to the title in any thread that the user has subscribed to.
The small icon is a clickable link which will take the user to a page where they can view all of their subscriptions.
This requires modifying forumdisplay.php and one template file "forumdisplaybit".
Also you must upload the image icon file to your images directory.
//Subscribed thread with S icon hack begin
$show_subscribed=''; // empty variable out for each pass in while loop
$s_iconhack_userid=$bbuserinfo['userid'];
$check_user_subscribed=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE threadid=$thread[threadid] AND userid='$s_iconhack_userid' LIMIT 1");
$subscribed_id=$check_user_subscribed[subscribethreadid];
if ($subscribed_id>0)
{
$show_subscribed=" <a href=\"member2.php?s=$session[sessionhash]&action=viewsubscription&daysprune=1000\"><img src=\"images/subscribed-icon.gif\" align=\"middle\" width=15 height=15 border=0 alt=\"You are subscribed to this thread. Click to view all subscriptions\"></A> ";
}
//Subscribed Icon Hack End
Now go into the admin cp and change the template forumdisplaybit as follows:
Good update. I'll test it out and then update to my original if ok w/you. I had tried the single database query similar to how you had it but missed a parameter I think on my "ON" clause which resulted in single threads showing up multiple times in a row on a page as my database query was not correct. Because of this I went the other route of a seperate query.
If your board is not heavily loaded you are just as well off with either version but if your board is more heavily loaded it's wise to save the query as you point out. I fall into the heavy traffic board so I'll be testing out the query and see if I can remember exactly why I couldn't get it just right back then. Thanks for helping out
Good update. I'll test it out and then update to my original if ok w/you. I had tried the single database query similar to how you had it but missed a parameter I think on my "ON" clause which resulted in single threads showing up multiple times in a row on a page as my database query was not correct. Because of this I went the other route of a seperate query.
[...]
Hi. Great hack even the variation.
Do you plan to update the original instructions, so long ?
Thanks
Originally posted by GK_ng as this Hack added a bunch of Queries, I did a redesign of this genious hack:
replace it with
Code:
SELECT $dotuserid $votequery ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postuserid,
lastposter,thread.dateline,views,thread.iconid,notes,thread.visible,sticky,votetotal,attach,subscribethread.subscribethreadid AS subscribed
FROM thread
LEFT JOIN subscribethread
ON (subscribethread.threadid=thread.threadid AND subscribethread.userid='".$bbuserinfo['userid']."')
".iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
$dotjoin
WHERE $threadids
ORDER BY sticky DESC, $sortfield $sqlsortorder
");
Full Credits to mvigod for the idea and the first release of this hack ...
Excuse me, GK_ng...
Just something.
Are you sure if inserting such a LEFT JOIN between
thread and subscribethread tables,
the later LEFT JOIN with the icon table
would be run correctly ?
Actually I think I tried the changes Gk-ng made and got an error so I had to change the query...I'll go back and see what I finally ended up with and repost the variation...my original is easiest for a lower volume board and if you really need to optimize by saving a query then the other version I'll post will work...have to go run through the changes I made now...
Thanks.
Hwr. I made it worked simply by moving the LEFT JOIN subscribethread ON .... just before the WHERE clause.
This way, the entire table BEFORE is left joint with the subscribethread....
Now it works fine... without adding any query to the page (verified by the Nakkid's Hack...)
This is the alternate form of this hack which will save the query which can be used. Either one will work fine but for those concerned about queries you may certainly wish to use this variation.
In forumdisplay.php
ADD THIS:
PHP Code:
//Subscribed hack begin
unset($show_subscribed); // empty variable out
if ($thread[subscribed])
{
$show_subscribed=" <a href=\"member2.php?s=$session[sessionhash]&action=viewsubscription&daysprune=1000\"><img
src=\"http://www.yourdomain.com/images/subscribed-icon.gif\" align=\"middle\" width=15 height=15 border=0 a
lt=\"You are subscribed to this thread. Click to view all subscriptions\"></A> ";
}
//Subscribed Hack End
$threads=$DB_site->query("
SELECT $dotuserid$votequery ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postuserid,
lastposter,thread.dateline,views,thread.iconid,notes,thread.visible,sticky,votetotal,attach
FROM thread
".iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
$dotjoin WHERE $threadids ORDER BY sticky DESC, $sortfield$sqlsortorder ");
Change to:
PHP Code:
$threads=$DB_site->query("
SELECT $dotuserid$votequery ".iif($foruminfo[allowicons],'icon.title as icontitle,icon.iconpath,','')."
thread.threadid,thread.title,lastpost, forumid,pollid,open,replycount,postusername,postuserid,
lastposter,thread.dateline,views,thread.iconid,notes,thread.visible,sticky,votetotal,attach,subscribethread.subscribethreadid AS subscribed
FROM thread
LEFT JOIN subscribethread ON (subscribethread.threadid=thread.threadid AND subscribethread.userid='".$bbuserinfo['userid']."')
".iif($foruminfo[allowicons],'LEFT JOIN icon ON (icon.iconid = thread.iconid)','')."
$dotjoin WHERE $threadids ORDER BY sticky DESC, $sortfield$sqlsortorder ");
Now change the template forumdisplaybit as follows: