Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Re: [carfac] Automatic Link to Subscribe to a forum

Quote Reply
Re: [carfac] Automatic Link to Subscribe to a forum In reply to
There are a couple ways to do this. The simplest way would be to create a global that gives you a list of the current subscribed forums, then simply pass all of them, as well as the new one.

global:
Code:
sub {
my $current = shift;
my @subscribed = $DB->table('ForumSubscriber')->select(
forum_id_fk => {
user_id_fk => $USER->{user_id}
}
)->fetchall_list;
my %ret;
for (@subscribed) {
if ($_ == $current) { $ret{subscribed} = 1 }
else { push @{$ret{subscribed_to}}, $_ }
}
\%ret;
}
The code above grabs all the subscribed forum ids and returns them, but if the forum_id you pass in is found, it returns a "subscribed" variable if it was found and DOESN'T return that ID in the list (allowing you to unsubscribe by simply not adding the ID).

So, in a template, you'd do something like:

Code:
<%global($forum_id)%>

<a href=".........gforum.cgi?<%loop subscribed_to
%>subscribe=<%loop_value%>;<%endloop
%><%unless subscribed%>subscribe=<%forum_id%>;<%endunless
%>do=user_pro......"><%if subscribed
%>Unsubscribe<%else
%>Subscribe<%endif%></a>

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Subject Author Views Date
Thread Automatic Link to Subscribe to a forum carfac 3848 Nov 19, 2003, 9:13 AM
Thread Re: [carfac] Automatic Link to Subscribe to a forum
Jagerman 3653 Nov 19, 2003, 1:25 PM
Thread Re: [Jagerman] Automatic Link to Subscribe to a forum
carfac 3667 Nov 19, 2003, 2:14 PM
Thread Re: [carfac] Automatic Link to Subscribe to a forum
Jagerman 3654 Nov 19, 2003, 2:20 PM
Post Re: [Jagerman] Automatic Link to Subscribe to a forum
carfac 3662 Nov 19, 2003, 4:22 PM