PDA

View Full Version : Forum Subscription Indicator/Links on ForumHome


kyrnel
05-09-2004, 10:00 PM
Description:

This hack will add an indicator to each Forum on ForumHome (and to subforums in ForumDisplay) that indicates whether the forum has been subscribed to.
The indicator can be clicked to Add/Remove the subscription to the forum.

Hack Overview:
Queries added: 0
Files to modify: 2 (1 if you have no subforums)
Templates to edit: 5
Phrases to add: 2
New Image files: 2

================================================== =======
Instructions:

<file edits>

Step 1) Edit index.php
Find:
cache_ordered_forums(1,);
and replace with:
cache_ordered_forums(1, 0, $bbuserinfo['userid']);

Step 2) Edit forumdisplay.php (only necessary if you have subforums)
Find:
cache_ordered_forums(1, 1);
and replace with:
cache_ordered_forums(1, 1, $bbuserinfo['userid']);

<phrase additions>

Step 3) Add GLOBAL phrase
Varname: subscribed_click_to_unsubscribe
Text: Currently Subscribed - Click to REMOVE Subscription

Step 4) Add GLOBAL phrase
Varname: unsubscribed_click_to_subscribe
Text: Currently UNsubscribed - Click to ADD Subscription

<template edits>

Step 5) Edit FORUMDISPLAY (only necessary if you have subforums)
Find:
<td class="thead" width="100%" align="$stylevar[left]">$vbphrase[forum]</td>
after it ADD:
<td class="thead">$vbphrase[subscribe]</td>

Step 6) Edit FORUMHOME (4 changes)
(1)Find:
<td class="tcat" colspan="<if condition="$vboptions['showmoderatorcolumn']">6<else />5</if>">
CHANGE it to:
<td class="tcat" colspan="<if condition="$vboptions['showmoderatorcolumn']">7<else />6</if>">

(2)Find:
<td class="alt1" colspan="<if condition="$vboptions['showmoderatorcolumn']">6<else />5</if>">
CHANGE it to:
<td class="alt1" colspan="<if condition="$vboptions['showmoderatorcolumn']">7<else />6</if>">

(3)Find:
<td class="thead" width="100%" align="$stylevar[left]">$vbphrase[forum]</td>
after it ADD:
<td class="thead">$vbphrase[subscribe]</td>

(4)Find:
<td class="tfoot" align="center" colspan="<if condition="$vboptions['showmoderatorcolumn']">6<else />5</if>">
CHANGE it to:
<td class="tfoot" align="center" colspan="<if condition="$vboptions['showmoderatorcolumn']">7<else />6</if>">

Step 7) Edit forumhome_forumbit_level1_nopost
Find:
<td class="tcat" colspan="<if condition="$vboptions[showmoderatorcolumn]">6<else />5</if>">
CHANGE to:
<td class="tcat" colspan="<if condition="$vboptions[showmoderatorcolumn]">7<else />6</if>">

Step 8) Edit forumhome_forumbit_level1_post
Find:
<if condition="$show['subforums']"><div class="smallfont" style="margin-top:$stylevar[cellpadding]px"><strong>$vbphrase[subforums]</strong>: $forum[subforums]</div></if>
</td>
</tr>
</table>

</td>

after it ADD:
<td class="alt1" align="center">
<if condition="$bbuserinfo['userid']"><table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<if condition="$forum[subscribeforumid]">
<a href="subscription.php?do=removesubscription&f=$forum[forumid]"><img src="./images/buttons/subscribed_new.gif" alt="$vbphrase[subscribed_click_to_unsubscribe]" border="0" align="absmiddle" /></a>
<else />
<a href="subscription.php?do=addsubscription&f=$forum[forumid]"><img src="./images/buttons/subscribe_new.gif" alt="$vbphrase[unsubscribed_click_to_subscribe]" border="0" align="absmiddle" /></a>
</if>
</td>
</tr>
</table></if>
</td>


Step 9) Edit forumhome_forumbit_level2_post
Find:
<if condition="$show['subforums']"><div class="smallfont" style="margin-top:$stylevar[cellpadding]px"><strong>$vbphrase[subforums]</strong>: $forum[subforums]</div></if>
</td>

after it ADD:
<td class="alt1" align="center">
<if condition="$bbuserinfo['userid']"><table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<if condition="$forum[subscribeforumid]">
<a href="subscription.php?do=removesubscription&f=$forum[forumid]"><img src="./images/buttons/subscribed_new.gif" alt="$vbphrase[subscribed_click_to_unsubscribe]" border="0" align="absmiddle" /></a>
<else />
<a href="subscription.php?do=addsubscription&f=$forum[forumid]"><img src="./images/buttons/subscribe_new.gif" alt="$vbphrase[unsubscribed_click_to_subscribe]" border="0" align="absmiddle" /></a>
</if>
</td>
</tr>
</table></if>
</td>


Step 10) Upload the image files (subscribe_new.gif and subscribed_new.gif) to the images/buttons folder.

That's it!
================================================== =======

Screencap and images attached...
Enjoy :)

kyrnel
05-10-2004, 09:41 PM
ARGHH! The Attachment Manager is not allowing me to upload GIFs and I can't link them from my site since I have hotlink protection enabled. So here is a ZIP file.

[Edit - I was able to upload a JPG of the screencap]

Boofo
05-10-2004, 09:43 PM
Can you please make a text file for this so it will be easier to download and install? ;)

And can we use the words Subscribe and Unsubscribe for this instead of images?

kyrnel
05-10-2004, 09:45 PM
Sure, sorry, this is my first real hack. :) Will upload shortly.

Boofo
05-10-2004, 09:46 PM
I just edited my post. Can we use words instead of images for this (as in my post above)?

kyrnel
05-10-2004, 09:48 PM
Certainly. That option would actually be much easier, since you dont really have to add a new column to the table.
Did you want a separate column, or just the text in the same cell as the Forum title?

Boofo
05-10-2004, 09:59 PM
I just want to add it underneath the forumd escription on a separate line and have it say Subscribe or Unsubscribe and have it change accordingly when it is clicked. vB2 used to have a hack like this and it was great! ;)

kyrnel
05-10-2004, 11:09 PM
OK, to JUST add a text link beneath the forum description, follow these steps:

1) Make file changes as indicated above (index.php and forumdisplay.php)
2) Edit forumhome_forumbit_level1_post
Find:
<if condition="$show['forumsubscription']"><div class="smallfont"><strong><a href="subscription.php?$session[sessionurl]do=removesubscription&amp;f=$forum[forumid]">$vbphrase[unsubscribe_from_this_forum]</a></strong></div></if>
and CHANGE to:
<if condition="$forum[subscribeforumid]"><div class="smallfont"><a href="subscription.php?$session[sessionurl]do=removesubscription&amp;f=$forum[forumid]">$vbphrase[unsubscribe]</a></div>
<else />
<div class="smallfont"><a href="subscription.php?$session[sessionurl]do=addsubscription&amp;f=$forum[forumid]">$vbphrase[subscribe]</a></div>
</if>
3) Make the exact same change as above to forumhome_forumbit_level2_post.

This will basically make the forums look like they currently do in the UserCP with the 'Unsubscribe" link.

I'd like to get some feedback and see if I need to make any other changes before I finalize these two options and make the associated text files. :)

Boofo
05-10-2004, 11:26 PM
Ok, I did like you said, and the subscribe link shows up but when I click on it and subscribe to a thread, it still says subscribe for the link. It doesn't change to unsubscribe.

Should it be saying subscribe on all of them, even the ones I am already subscribed to?

Boofo
05-10-2004, 11:30 PM
This is the code I have for the indedx.php:

cache_ordered_forums(1);

It doesn't have a second number. Now if I add that second number, then it works like it should. But is that going to mess up the moderator cache that way?

kyrnel
05-11-2004, 12:09 AM
You're right. The '0' wont change anything because the default value is 0 for that function.

I have updated the instructions. The next file edit was wrong as well, I fixed it too.

MrNase
05-11-2004, 04:22 AM
Hey,

this could come in handy when i use subscriptions :)

thx

Boofo
05-11-2004, 05:05 AM
You're right. The '0' wont change anything because the default value is 0 for that function.

I have updated the instructions. The next file edit was wrong as well, I fixed it too.
I don't see any difference in the forumdisplay.php file edit. It looks the same to me. ;)

Now this won't work with forums you are already subscribed to, right? Any way to run a query to set it up like that? ;)

kyrnel
05-11-2004, 12:28 PM
It was the "Find:" code that was wrong for forumdisplay.php, not the replacement code.

Basically how it works is this:
When you pass the userid to the cache_ordered_forums() function it adds the field [subscribeforumid] to the query. If this field is populated with a value, then that means that you are subscribed to that forum. So it doesnt add any queries, but it makes an existing query slightly more complex.

So it will work with existing subscriptions. No need to update anything.

Boofo
05-11-2004, 03:25 PM
Ahhh, ok, that makes more sense now. Thank you for the explanation. I was wondering how it worked. ;)

Boofo
05-11-2004, 04:22 PM
Any way to make the links work in the Forum tools dropdown? ;)

kyrnel
05-11-2004, 04:28 PM
That is a good question. I will have to look into that. I expect that it will require a different approach since the forum details in ForumDisplay (other than subforums) are not generated by the cache_ordered_forums function.

Actually, this has already been done in another hack, here:
https://vborg.vbsupport.ru/showthread.php?t=63373&highlight=unsubscribe+forum

Boofo
05-11-2004, 05:06 PM
That is a good question. I will have to look into that. I expect that it will require a different approach since the forum details in ForumDisplay (other than subforums) are not generated by the cache_ordered_forums function.

Actually, this has already been done in another hack, here:
https://vborg.vbsupport.ru/showthread.php?t=63373&highlight=unsubscribe+forum

Thank you, sir. Apparently I had already clicked install in that thread but never installed it. Must have forgotten about it. ;)

Your hack works like a charm. Thank you, again. ;)

kyrnel
05-12-2004, 12:48 PM
Well, if there are no more comments/questions, then I will go ahead and write this up as a full release.

There is actually little that can go wrong with this hack since it mostly utilizes the existing code in vB. I just wanted to make sure that my instructions were accurate.

Boofo
05-12-2004, 01:14 PM
Accurate and excellent! ;)

InfoNirvana
06-03-2007, 06:37 PM
I'd like this for 3.6