PDA

View Full Version : [code release] Redirect to forum instead of thread after post


Gutspiller
08-25-2001, 10:00 PM
After you post a message it takes you back to the message you just posted. How would I make it so that instead of doing that, take the users back to forum main forum that they posted in?

Any help is appreciated.

Thanks!

Admin
08-26-2001, 05:33 PM
.

samtha25
08-27-2001, 07:31 PM
Just what I was looking for!

Thanks, Firefly. You're a wonder. :)

Admin
08-27-2001, 07:34 PM
Thank you! :)

If you want, I can add this as an option, under the "Show Signature" and its friends, something like "Send to forum".
Are you interested?

samtha25
08-27-2001, 07:37 PM
If you mean a user-selectable option in their options, that would be terrific. I was just thinking it would be nice to make it user-selectable.

Admin
08-27-2001, 07:58 PM
Alrighty. :)

Undo all changes (from my first post).
In newreply.php replace
// redirect
if ($prevpost[visible]) {
with
// redirect
if ($prevpost[visible] && !$sendtoforum) {
In newthread.php replace
} elseif ($visible) {
$goto="showthread.php?s=$session[sessionhash]&threadid=$threadid";
with
} elseif ($visible && !$sendtoforum) {
$goto="showthread.php?s=$session[sessionhash]&threadid=$threadid";
And in poll.php replace
// redirect
if ($threadinfo[visible]) {
with
// redirect
if ($threadinfo[visible] && !$sendtoforum) {
Now, in your newreply and newthread templates, add this code
<br><input type="checkbox" name="sendtoforum" value="yes"> <b>Go back to forum:</b> after posting would you like to return to the forum.
right after
<br><input type="checkbox" name="signature" value="yes" $signaturechecked> <b>Show Signature:</b> include your profile signature. Only registered users may have signatures.
You can change the text, but don't touch the tags please. :)
That's about it - don't forget the last edit needs to be done on both newreply and newthread templates!

I tested this on my forums, so you shouldn't have any problems. :)

EDIT:
A little tip - if you want the checkbox to be selected by default, add checked right after value="yes" in the code you added to your templates.

EDIT 2:
This could be expanded even more - having an option for the user in their profile options, and making that option decide wheter the box is checked by default, or not.
If you are interested in this, please let me know and I'll work on it tomorrow. :)

Gutspiller
08-27-2001, 08:06 PM
Is there a way to make it so the user has control over what the default is?

Some of my users want it one way, and others want it the other way. I don't want to set it to default because then they will have to uncheck it if they don't want it. (I know that's better than not having the checkbox at all) but if it's possible it would be nice to give the users a place in their profile. Is this possible or does this then start to become a hack? :(

Admin
08-27-2001, 08:12 PM
[QUOTE]Originally posted by FireFly
EDIT 2:
This could be expanded even more - having an option for the user in their profile options, and making that option decide wheter the box is checked by default, or not.
If you are interested in this, please let me know and I'll work on it tomorrow. :)

samtha25
08-27-2001, 11:09 PM
Very nice work, Firefly! You've got two approachs there that forum admins might decide to use.

It would be great to have this in the user profile, but there is something to be said for having it selected from newreply, as in some cases someone might be replying to different posts in a thread as they go and want to return to the thread, while in other cases they might be making only one reply or making their last reply and want to return to the forum.

I can't say I see where someone starting a newthread would want to return to their new post, unless to check it. With Preview, though, it doesn't seem necessary.

So, maybe what would work best is to let the user set a default behavior but then be able to also change it from the posting pages. Heh, not too much to ask, right?

I've seen UBB hacks that let the poster select where to go from the redirect message, but usually it flies by too fast for people to make the selection or pauses in which case it usually becomes annoying to be forced to click.

Admin
08-28-2001, 05:55 AM
The user now has full control over this.

1. In the newreply and newthread replace
<br><input type="checkbox" name="sendtoforum" value="yes"> <b>Go back to forum:</b> after posting would you like to return to the forum.
with
<br><input type="checkbox" name="sendtoforum" value="yes" $sendtoforumchecked> <b>Go back to forum:</b> after posting would you like to return to the forum.
in both templates!

2. In the modifyoptions add this code
<tr>
<td bgcolor="#DFDFDF"><normalfont><b>Use 'Send to forum' by default?</b></normalfont><br>
<smallfont>Using this option will send you back to the forum after posting a new message.</smallfont></td>
<td bgcolor="#DFDFDF"><normalfont>
<input type="radio" name="sendtoforumdef" value="yes" $sendtoforumdefchecked> yes
<input type="radio" name="sendtoforumdef" value="no" $sendtoforumdefnotchecked> no
</normalfont></td>
</tr>
right after
<tr>
<td bgcolor="#DFDFDF"><normalfont><b>Use 'Email Notification' by default?</b></normalfont><br>
<smallfont>Using this option emails you whenever someone replies to a thread that you have participated in.</smallfont></td>
<td bgcolor="#DFDFDF"><normalfont>
<input type="radio" name="emailnotification" value="yes" $emailnotificationchecked> yes
<input type="radio" name="emailnotification" value="no" $emailnotificationnotchecked> no
</normalfont></td>
</tr>

3. In newreply.php replace
if ($bbuserinfo[emailnotification]!=0) {
$emailchecked="checked";
}
with
if ($bbuserinfo[emailnotification]) {
$emailchecked="checked";
}
if ($bbuserinfo[sendtoforumdef]!=0) {
$sendtoforumchecked="checked";
}

4. In newthread.php replace
if ($bbuserinfo[emailnotification]) {
$emailchecked="checked";
}
with
if ($bbuserinfo[emailnotification]) {
$emailchecked="checked";
}
if ($bbuserinfo[sendtoforumdef]!=0) {
$sendtoforumchecked="checked";
}

5. In member.php replace
$emailnotification=iif($emailnotification=="yes",1,0);
with
$emailnotification=iif($emailnotification=="yes",1,0);
$sendtoforumdef=iif($sendtoforumdef=="yes",1,0);
Also replace
$DB_site->query("UPDATE user
SET ".$updatestyles."adminemail='$adminemail',
showemail='$showemail',invisible='$invisible',cook ieuser='$cookieuser',
maxposts='".addslashes($umaxposts)."',daysprune='".addslashes($prunedays)."',
timezoneoffset='".addslashes($timezoneoffset)."',emailnotification='$emailnotification',
startofweek='".addslashes($startofweek)."',options='$options',receivepm='$receivepm',
emailonpm='$emailonpm',pmpopup='$pmpopup',usergrou pid='$bbuserinfo[usergroupid]',
nosessionhash='$nosessionhash'
WHERE userid='$bbuserinfo[userid]'");
with
$DB_site->query("UPDATE user
SET ".$updatestyles."adminemail='$adminemail',
showemail='$showemail',invisible='$invisible',cook ieuser='$cookieuser',
maxposts='".addslashes($umaxposts)."',daysprune='".addslashes($prunedays)."',
timezoneoffset='".addslashes($timezoneoffset)."',emailnotification='$emailnotification',sendtofor umdef='$sendtoforumdef',
startofweek='".addslashes($startofweek)."',options='$options',receivepm='$receivepm',
emailonpm='$emailonpm',pmpopup='$pmpopup',usergrou pid='$bbuserinfo[usergroupid]',
nosessionhash='$nosessionhash'
WHERE userid='$bbuserinfo[userid]'");
and add
if ($bbuserinfo[sendtoforumdef]) {
$sendtoforumdefchecked="checked";
$sendtoforumdefnotchecked="";
} else {
$sendtoforumdefchecked="";
$sendtoforumdefnotchecked="checked";
}
right after
if ($bbuserinfo[emailnotification]) {
$emailnotificationchecked="checked";
$emailnotificationnotchecked="";
} else {
$emailnotificationchecked="";
$emailnotificationnotchecked="checked";
}

6. And last but by no means least, run this SQL query:
ALTER TABLE user ADD sendtoforumdef SMALLINT(6) DEFAULT '0' not null AFTER emailnotification

This is it. I skipped adding this info to the register because it really doesn't matter, there are some option that are not available there as well, so it's not the end of the world.

Hope this is what you want. :)

Kier
08-28-2001, 07:05 AM
[moved to hack releases forum]

RobAC
08-28-2001, 12:25 PM
Would it be possible to get this into a nice clean release version...zip file, etc,.? :)

Gutspiller
08-28-2001, 03:02 PM
how exactly do I run the SQL query?

I don't know how to do that. :(

Admin
08-28-2001, 03:32 PM
[QUOTE]Originally posted by RobAC
Would it be possible to get this into a nice clean release version...zip file, etc,.? :)

Gutspiller
08-28-2001, 04:04 PM
Im sorry but that very first line in the hack you tell me to find in newthread and newreply cannot be found. Uh, are you sure? :(

Admin
08-28-2001, 04:06 PM
You must first do what it says in this post:
http://www.vbulletin.com/forum/showthread.php?s=&postid=162037

Gutspiller
08-28-2001, 04:30 PM
Originally posted by FireFly
You must first do what it says in this post:
http://www.vbulletin.com/forum/showthread.php?s=&postid=162037

Well you might want to change this then

"Alrighty.

Undo all changes (from my first post)."

Because that's what I did. So you might want to take that out because it confused me. I don't know if it would confuse others though.

Admin
08-28-2001, 04:39 PM
Like I said, I will post this hack in a clean and ordered form tomorrow.

Gutspiller
08-28-2001, 04:46 PM
Originally posted by FireFly
Like I said, I will post this hack in a clean and ordered form tomorrow.

I don't have that long! I must implement hack NOW! :D

Admin
08-28-2001, 04:54 PM
Alright, then do everything I said in my posts. (I edited out what's not needed)

Gutspiller
08-28-2001, 05:06 PM
Originally posted by FireFly
Alright, then do everything I said in my posts. (I edited out what's not needed)

When I run that query thingy at the end of the "mini hack" (I already installed your SQL queru) it gives me this error:

There seems to have been a slight problem with the database. Please try again by pressing the refresh button in your browser.

An E-Mail has been dispatched to our Technical Staff, who you can also contact if the problem persists.

We apologise for any inconvenience.


Database error in vBulletin Control Panel: Invalid SQL: ALTER TABLE `vbulletin`.`user` ADD `sendtoforumdef` SMALLINT(6) DEFAULT '0' not null AFTER `emailnotification`
mysql error: Access denied for user: 'theforum_Gutspil@localhost' to database 'vbulletin'
mysql error number: 1044
Date: Tuesday 28th of August 2001 02:04:13 PM
Script: /forumz/admin/query.php
Referer: http://www.theforumz.com/forumz/admin/query.php



Question: Did you test this hack or am I your lab rat? :(

Admin
08-28-2001, 05:13 PM
[QUOTE]Originally posted by Gutspiller
Question: Did you test this hack or am I your lab rat? :(

Gutspiller
08-28-2001, 05:31 PM
Tested and works!

I did change when you said

#DFDFDF


to


{secondaltcolor}


and it makes it so there are two greys in around instead of alternating, but it's ok.

And also when you said to look for this code:


if ($bbuserinfo[emailnotification]) {
$emailnotificationchecked="checked";
$emailnotificationnotchecked="";
} else {
$emailnotificationchecked="";
$emailnotificationnotchecked="checked";
}


and replace it with this code:


if ($bbuserinfo[sendtoforumdef]) {
$sendtoforumdefchecked="checked";
$sendtoforumdefnotchecked="";
} else {
$sendtoforumdefchecked="";
$sendtoforumdefnotchecked="checked";
}


It was above the previous searched code, so you have to scroll to the top. So that step should be before the other steps in the member.php.

I think that's it.

Thanks for the mini (yet kick ass) hack. :D

Gutspiller
08-28-2001, 05:45 PM
OOPS!

For some reason when posting a reply it isn't sending me back to the forum, even though I double checked that is what I set it too. :(

Ideas?

Admin
08-28-2001, 05:50 PM
Sounds like you didn't do changes for newreply.php, newthread.php and poll.php from my first post (Alrighty. Undo all changes (from my first post)).

cyrus
08-28-2001, 05:52 PM
waiting for clean hack

thanks fire

Admin
08-28-2001, 06:07 PM
There you go! :)
http://www.vbulletin.com/forum/showthread.php?s=&threadid=26734

Gutspiller
08-28-2001, 06:09 PM
Originally posted by FireFly
Sounds like you didn't do changes for newreply.php, newthread.php and poll.php from my first post (Alrighty. Undo all changes (from my first post)).

You know you make this harder than it has to be. ;)

I think I did that thread.

When creating a new THREAD it works, but when creating a new REPLY it doesn't work. I checked the newreply template and this is whats in there



<br><input type="checkbox" name="signature" value="yes" $signaturechecked> <b>Show Signature:</b> include your profile signature. Only registered users may have signatures.<br><input type="checkbox" name="sendtoforum" value="yes" $sendtoforumchecked> <b>Go back to forum:</b> after posting would you like to return to the forum.
</smallfont></td>

Isn't that where the only change is, in that template? :(

Admin
08-28-2001, 06:13 PM
I do not know what you did / did not do, so please just undo everything and follow the new instructions.

And this is not hard at all - just do everything I say in this thread and you'll get it done.

Gutspiller
08-28-2001, 06:17 PM
undo it :confused:

That will take quite some time. I just double checked the newreply template and the newreply.php and everything you stated is in there.

Yes, I would like see another board using this hack please. :D

That way I can test the reply function of this hack. :)

Admin
08-28-2001, 06:21 PM
You're gonna have to believe me.
I will not post the URL to my demo boards as it's on my personal computer and I still don't have any security utilities installed.

Gutspiller
08-28-2001, 06:29 PM
:( ok so I need to remove all previous hacks, that were in that thread? THat aint going to be very easy. :(

Admin
08-28-2001, 06:33 PM
Why?
If it says replace A with B, and you did it, simply replace B with A.
And if it says add A after B, and you did it, simply remove A from after B.

Gutspiller
08-28-2001, 06:53 PM
Originally posted by FireFly
Why?
If it says replace A with B, and you did it, simply replace B with A.
And if it says add A after B, and you did it, simply remove A from after B.

You forget that there was 3 different versions of A and B though. Adding and taking away. :p You made 3 different modifications and that's what not only makes it hard, but confusing as well.

Admin
08-28-2001, 06:57 PM
If you can take care of the templates, I'm willing to fix your files.
If you want, e-mail them to firefly@poolie.net.
(Is exchanging files allowed?)

Gutspiller
08-28-2001, 07:47 PM
Just redid it all. Still same thing :(

Do I need to run that SQL query thing again?

Admin
08-29-2001, 05:59 AM
No.

BBInsider
08-31-2001, 06:41 PM
Guys, newbie here, could you please exaclty tell me step for step where I find "newreply.php" I looked everywhere, is it in my Templates? I looked in Newreply but couldnt find it anywhere.. HELP!!!!

Thanks

Its kinda lame to have someone post a reply and be redirected back to the bottom of his/her thread. They want to be back into the main board not back in the thread they were just in, this should be a fix in 2.0.3 but wasn't.

Thanks again!

Gutspiller
08-31-2001, 07:40 PM
Originally posted by BBInsider
Guys, newbie here, could you please exaclty tell me step for step where I find "newreply.php" I looked everywhere, is it in my Templates? I looked in Newreply but couldnt find it anywhere.. HELP!!!!

Thanks

Its kinda lame to have someone post a reply and be redirected back to the bottom of his/her thread. They want to be back into the main board not back in the thread they were just in, this should be a fix in 2.0.3 but wasn't.

Thanks again!

.php extensions can be found in the directories. You need to login to your server and find the files inside your forum directory. Then download them to your PC and do a search for whatever is being said to look for in the tutorials. Then (I) backup the file on the server by either putting a "1" in front of it or moving it to a folder labeled what the hack is that replaced it. Then I uploaded the one from the PC to the server.

Go check forums to see if it looks right and there isn't any troubles.

BBInsider
08-31-2001, 08:31 PM
Great help bro! I didnt know thats where to look for all this. I guess many assume that everyone here knows that, but as more and more board licenses are sold, you get more and more newbies! I appreciate you taking the time to help.

Cheers! :D

NYI Fan
11-15-2001, 10:31 PM
I had this installed on 2.0.3, and my users loved it, but since the upgrade to 2.2.0, it no longer works.
Firefly, should I just redo all the steps I took originally, including the query, or is there specific changes for 2.2.0?

Thx
NYI

(I feel like i have been doing nothing but asking you questions tonight - sorry ;) )

Admin
11-16-2001, 11:22 AM
I think you only need to apply the file changes again, not running the query though.

NYI Fan
11-16-2001, 03:08 PM
great thanks
i'll give it a try tonight when i get home from work.

:)