[Beta] Login and jump to post

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Post Reply
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

[Beta] Login and jump to post

Post by Merlin Sythove »

If you follow a link to a post, maybe from a topic watch message, that looks like this
http://www.mydomain.com/forum/viewtopic.php?p=248930#248930
but you have to log in first, the direct jump to the post is lost, like this:
http://www.mydomain.com/forum/viewtopic.php?p=248930
At least, that is how things work on my forum.

Use the following micro-mod to solve this problem:
In functions.php find

Code: Select all

function redirect($url)
{
Find the end of that function:

Code: Select all

	header('Location: ' . $server_protocol . $server_name . $server_port . $script_name . $url);
Add before that

Code: Select all

	//If redirecting to a post, the post marker "#$post_id" may have been lost by now. Add it.
	//Typically happens after login.php
	if (strpos($url, POST_POST_URL . "=") && ! strpos($url, "#"))
	{
		$regexp = ".*[&?]" . POST_POST_URL . "=([0-9]*).*";
		$url = preg_replace('/' . $regexp . '/', $url . '#\\1', $url);
	}
This will see if the string "p=" followed by a number, is present, indicating direction to a post, and if so, it will add "#" plus the post number to the end of the URL.
Need custom work done? Pimp My Forum!
Hannibal_King
Registered User
Posts: 436
Joined: Mon Apr 03, 2006 6:24 am
Location: SLOVAKIA
Contact:

Re: [Beta] Login and jump to post

Post by Hannibal_King »

smooth :wink: and what about creating a mod that after deleting a post will redirect you right to the previous post, as you sure know, in phpBB 2.0.22 after deleting a post in topic, you will be redirected to the first post on first page, but what about if you are in topic that is on 15 pages? :D
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: [Beta] Login and jump to post

Post by Merlin Sythove »

Hannibal_King wrote:smooth :wink: and what about creating a mod that after deleting a post will redirect you right to the previous post, as you sure know, in phpBB 2.0.22 after deleting a post in topic, you will be redirected to the first post on first page, but what about if you are in topic that is on 15 pages? :D
Sounds like a good idea for a mod, be my guest :D
Need custom work done? Pimp My Forum!
Hannibal_King
Registered User
Posts: 436
Joined: Mon Apr 03, 2006 6:24 am
Location: SLOVAKIA
Contact:

Re: [Beta] Login and jump to post

Post by Hannibal_King »

that should be an inspiration for you :D
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: [Beta] Login and jump to post

Post by Merlin Sythove »

It is, thanks for inspiring me.
Need custom work done? Pimp My Forum!
Post Reply

Return to “[2.0.x] MODs in Development”