Current time: 05-23-2012, 02:47 AM Hello There, Guest! (LoginRegister)


 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[F] Thread mode and multipage [C-Chris]
02-22-2009, 11:01 PM
Post: #1
[F] Thread mode and multipage [C-Chris]
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:
PHP Code:
// Which thread mode is our user using? 
Below add:
PHP Code:
$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:
PHP Code:
$multipage multipage($postcount$perpage$pagestr_replace("{tid}"$tidTHREAD_URL_PAGED.$highlight)); 
Replace with:
PHP Code:
$multipage multipage($postcount$perpage$pagestr_replace("{tid}"$tidTHREAD_URL_PAGED.$highlight.$threadmode)); 

Greets,
Michael
-------------
[Image: donation_drive_sig.png]
Visit this user's website Find all posts by this user
02-24-2009, 02:39 PM
Post: #2
RE: Thread mode and multipage
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.

Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary
Visit this user's website Find all posts by this user
02-24-2009, 03:00 PM
Post: #3
RE: Thread mode and multipage
(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]
Visit this user's website Find all posts by this user
02-24-2009, 03:16 PM
Post: #4
RE: Thread mode and multipage
My bad, should've scrolled to the right. Toungue

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

PHP Code:
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...

Google SEO | Gravatar | Hooks | HTMLPurifier | Overview | Patches | PluginLibrary
Visit this user's website Find all posts by this user
03-10-2009, 07:02 PM
Post: #5
RE: Thread mode and multipage
Proposed fix. In showthread.php find:

PHP Code:
// 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$pagestr_replace("{tid}"$tidTHREAD_URL_PAGED.$highlight)); 

replace with

PHP Code:
// 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$pagestr_replace("{tid}"$tidTHREAD_URL_PAGED.$highlight.$threadmode)); 
Visit this user's website Find all posts by this user
03-10-2009, 10:19 PM
Post: #6
RE: Thread mode and multipage
Seems to be working great.

Greets,
Michael
-------------
[Image: donation_drive_sig.png]
Visit this user's website Find all posts by this user
03-15-2009, 11:50 PM
Post: #7
[F] Thread mode and multipage
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
Visit this user's website Find all posts by this user


Forum Jump:


User(s) browsing this thread:

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication