Redirect page after moving topic

Discussion forum for MOD Writers regarding MOD Development.
Locked
theallzaz
Registered User
Posts: 84
Joined: Tue Apr 16, 2013 2:41 pm

Redirect page after moving topic

Post by theallzaz » Fri Jun 28, 2013 10:02 pm

When a moderator try to move a topic, he receive the message below, right?

The selected topic has been moved successfully.
Return to the previous page
Return to the forum last visited
Go to the new forum


Furthermore, if he does not click on any of the options, the moderator is automatically redirected to "Return to the previous page" after 3 seconds. There is a way to make Return to the forum last visited by default? Because I have a plugin and for bug reasons i am trying to make this by default. I found the code of that page, in root/includes/mcp/mcp_main.php

Code: Select all

		$message = $user->lang[$success_msg];
		$message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id") . '">', '</a>');
		$message .= '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
		$message .= '<br /><br />' . sprintf($user->lang['RETURN_NEW_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$to_forum_id") . '">', '</a>');
I tried to reverse the order of them, but the only thing that changed was the "screen", because the user continued being redirected to the Return to the forum last visited.

Anyone know if there is a way to change this?

Thank you

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51877
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Redirect page after moving topic

Post by Brf » Fri Jun 28, 2013 10:31 pm

The order of the links in the message is irrelevant. The redirect is in the meta statement.

theallzaz
Registered User
Posts: 84
Joined: Tue Apr 16, 2013 2:41 pm

Re: Redirect page after moving topic

Post by theallzaz » Fri Jun 28, 2013 11:18 pm

Brf wrote:The order of the links in the message is irrelevant. The redirect is in the meta statement.
I don't understand about phpBB coding, but do you know what file i need to edit? Do you know what code can change the default action?

User avatar
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom Catullo
Contact:

Re: Redirect page after moving topic

Post by Tom » Sat Jun 29, 2013 1:08 am

Well, if it makes you feel any better, you're looking in the right place. :)

To change the redirect to point to the forum last visited instead of the "previous page", open /includes/mcp/mcp_main.php and find the following code:

Code: Select all

    $redirect = request_var('redirect', "index.$phpEx");
    $redirect = reapply_sid($redirect);

    if (!$success_msg)
    {
        redirect($redirect);
    }
    else
    {
        meta_refresh(3, $redirect);

        $message = $user->lang[$success_msg];
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id") . '">', '</a>'); 
Replace it with this:

Code: Select all

    $old_redirect = request_var('redirect', "index.$phpEx");
    $old_redirect = reapply_sid($redirect);
    $redirect = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id");

    if (!$success_msg)
    {
        redirect($redirect);
    }
    else
    {
        meta_refresh(3, $redirect);

        $message = $user->lang[$success_msg];
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $old_redirect . '">', '</a>');
        $message .= '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>'); 
And that's it! I've tested it on a local installation of phpBB and it appears to produce the desired behavior.
Tom Catullo - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51877
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Redirect page after moving topic

Post by Brf » Sat Jun 29, 2013 3:27 am

Yes. The redirect in the meta, immediately before the code that was posted already.

User avatar
Tom
Former Team Member
Posts: 2665
Joined: Tue Jun 20, 2006 2:12 am
Name: Tom Catullo
Contact:

Re: Redirect page after moving topic

Post by Tom » Sat Jun 29, 2013 10:25 am

Well, he seemed a bit confused as to where exactly he should edit the code, so I just wanted to help make it clear. ;)
Tom Catullo - Former Moderator Team Member
phpBB3 Smiley Pak Generator | Legend Repositioning MOD | My GitHub | My Site

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51877
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Redirect page after moving topic

Post by Brf » Sat Jun 29, 2013 2:12 pm

Yeah. I would have posted the code myself, but I do not have access to code from my iPad ;)

Locked

Return to “[3.0.x] MOD Writers Discussion”