Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] Thread mode and multipage [C-Chris]
#1
Example: The forum's default thread mode is the threaded mode. If you switch to the linear mode and you go to another page of the thread it's shown in the threaded mode again.

The problem is that the mode is not transfered in the multipage links.

Possible fix:

Open the file showthread.php and search for:
// Which thread mode is our user using?
Below add:
$threadmode = "";
if(isset($mybb->input['mode']) && $mybb->input['mode'] == "linear")
{
	if(($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1)) && $mybb->input['highlight'] == "")
	{
		$threadmode = "?mode=linear";
	}
	else
	{
		$threadmode = "&mode=linear";
	}
}
Search for:
$multipage = multipage($postcount, $perpage, $page, str_replace("{tid}", $tid, THREAD_URL_PAGED.$highlight));
Replace with:
$multipage = multipage($postcount, $perpage, $page, str_replace("{tid}", $tid, THREAD_URL_PAGED.$highlight.$threadmode));
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
#2
This user has been denied support. This user has been denied support.
Doesn't this add ? twice in case of both $highlight and $threadmode?

This ? or & is done in several places in MyBB already (for multipage, search highlights, etc), maybe it would be nicer to make a function for it that takes url and param(s) and uses either ? or & depending on wether there actually already is a ? in the URL part.
#3
(02-24-2009, 02:39 PM)frostschutz Wrote: Doesn't this add ? twice in case of both $highlight and $threadmode?
No, because it checks if $mybb->input['highlight'] is empty or not.
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
#4
This user has been denied support. This user has been denied support.
My bad, should've scrolled to the right. Toungue

inc/functions.php::fetch_page_url() actually already does something like this:

if(strpos($url, "?") === false)
{
    $url .= "?";
}
else
{
    $url .= "&";
}
$url .= "page=$page";

It's a much smarter way to append parameters than basing the decision on a seo setting and the existance of other parameters.

If something like this was moved to a separate function for joining query strings with URLs, you could get rid of the complicated seourls autodetect enabled or not, other params already present or not if, set $threadmode directly (without ? or &amp) and call joinquery($url, $highlight, $threadmode).

I know I'm not allowed to complain because it's a third party plugin, but appending &amp or ? based on the MyBB seourls setting is causing me some minor headache with my Google SEO plugin, for search.php does the very same thing, it appends to get_forum/post_link(). And the result is either "site&highlight=x" or "site?post=x?highlight=x" because the assumptions it makes do not apply when my plugin is in use.

With a function that appends query strings by actually checking for ? first this problem wouldn't exist...
#5
Proposed fix. In showthread.php find:

// Work out if we have terms to highlight
		$highlight = "";
		if($mybb->input['highlight'])
		{
			if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1))
			{
				$highlight = "?highlight=".urlencode($mybb->input['highlight']);
			}
			else
			{
				$highlight = "&highlight=".urlencode($mybb->input['highlight']);
			}
		}

		$multipage = multipage($postcount, $perpage, $page, str_replace("{tid}", $tid, THREAD_URL_PAGED.$highlight));

replace with

// Work out if we have terms to highlight
		$highlight = "";
		$threadmode = "";
		if($mybb->settings['seourls'] == "yes" || ($mybb->settings['seourls'] == "auto" && $_SERVER['SEO_SUPPORT'] == 1))
		{
			if($mybb->input['highlight'])
			{
				$highlight = "?highlight=".urlencode($mybb->input['highlight']);
			}
			
			if($mybb->input['mode'] == "linear" && $highlight)
			{
				$threadmode = "&mode=linear";
			}
			else
			{
				$threadmode = "?mode=linear";
			}
		}
		else
		{
			if($mybb->input['highlight'])
			{
				$highlight = "&highlight=".urlencode($mybb->input['highlight']);
			}
			
			if($mybb->input['mode'] == "linear")
			{
				$threadmode = "&mode=linear";
			}
		}

		$multipage = multipage($postcount, $perpage, $page, str_replace("{tid}", $tid, THREAD_URL_PAGED.$highlight.$threadmode));
#6
Seems to be working great.
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
#7
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group


Forum Jump:


Users browsing this thread: 1 Guest(s)