============================================================================================================================
Modification Title: Previous And Next Thread Links
Version: 1.0

Author: Area51Mafia, John Briggs

Description: This modification will provide previous and next thread links in the top of the thread view for naviagting to the next and previous threads.

Copyright:  2010 John Briggs. All rights reserved.

Compatability: XMB 1.9.5 SP1

Install Note: Before adding this modification to your forum, you should back up all files related to this modification.

License Note: This modification is released under the GPL License. A copy is provided with this software package.

Author Note:
You downloaded this modification from XMBGarage.com, the #1 source for XMB related downloads.
Please visit http://www.xmbgarage.com/ for support.
============================================================================================================================
=======
Step 1:
=======
=======================
Edit File: lang/English.lang.php
=======================
============================
Add Code To End Of File Above ?>
============================

// Previous And Next Thread Links Mod Begin
$lang['prevthread_none'] = "There is no older thread in this forum.";
$lang['nextthread_none'] = "There is no newer thread in this forum.";
$lang['prevthread'] = "View Previous Thread";
$lang['nextthread'] = "View Next Thread";
// Previous And Next Thread Links Mod End

============================================================================================================================
=======
Step 2:
=======
===============
Edit File: misc.php
===============
==========
Find Code:
==========

        if (isset($tsub[$tid])) {
            $location = $lang['onlineviewthread'].' '.$tsub[$tid];
        } else {
            $query = $db->query("SELECT t.fid, t.subject FROM $table_forums f, $table_threads t WHERE $restrict AND f.fid=t.fid AND t.tid='$tid'");
            while ($locate = $db->fetch_array($query)) {
                $location = $lang['onlineviewthread'].' '.censor($locate['subject']);
                $tsub[$tid] = $locate['subject'];
            }
        }

===============
Add Code Below:
===============

        // Previous and Next Threads Mod Begin
        if (false !== strpos($url, 'action=next')) {
            $url = substr($url, 0, strpos($url, '?'));
            $url .= '?tid='.$tid;
        }
        if (false !== strpos($url, 'action=prev')) {
            $url = substr($url, 0, strpos($url, '?'));
            $url .= '?tid='.$tid;
        }
        // Previous and Next Threads Mod End

============================================================================================================================
=======
Step 3:
=======
===================
Edit File: viewthread.php
===================
==========
Find Code:
==========

    eval('echo stripslashes("'.template('viewthread_printable').'");');

===============
Add Code Below:
===============

// Previous and Next Threads Mod Begin
} elseif ($action == 'next') {
    $query = $db->query("SELECT t.tid as t_tid FROM $table_threads t LEFT JOIN $table_threads o ON o.tid='$tid' WHERE t.lastpost > o.lastpost AND t.fid='$fid' ORDER BY t.lastpost ASC LIMIT 1");
    if ($db->num_rows($query) != 1) {
        error($lang['nextthread_none']);
    }
    $nthread = $db->fetch_array($query);
    $db->free_result($query);
    $nextthreadid = intval($nthread['t_tid']);
    redirect('viewthread.php?tid='.$nextthreadid, 0);
} elseif ($action == 'prev') {
    $query = $db->query("SELECT t.tid as t_tid FROM $table_threads t LEFT JOIN $table_threads o ON o.tid='$tid' WHERE t.lastpost < o.lastpost AND t.fid='$fid' ORDER BY t.lastpost DESC LIMIT 1");
    if ($db->num_rows($query) != 1) {
        error($lang['prevthread_none']);
    }
    $pthread = $db->fetch_array($query);
    $db->free_result($query);
    $prevthreadid = intval($pthread['t_tid']);
    redirect('viewthread.php?tid='.$prevthreadid, 0);
// Previous and Next Threads Mod End

============================================================================================================================
=======
Step 4:
=======
===============================
Go To Administration Panel --> Templates
===============================
====================
Edit Template: viewthread
====================
==========
Find Code:
==========

<tr>
<td width="18%" class="header">$lang[textauthor] </td>
<td class="header">$lang[textsubject] $thread[subject]</td>
</tr>

===============
Add Code Above:
===============

<tr>
<td class="category" colspan="2">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="navtd" align="left" width="50%"><font class="smalltxt"><strong>&laquo; <a href="viewthread.php?tid=$tid&amp;action=prev">$lang[prevthread]</a></strong></font></td>
<td class="navtd" align="right" width="50%"><font class="smalltxt"><strong><a href="viewthread.php?tid=$tid&amp;action=next">$lang[nextthread]</a> &raquo;</strong></font></td>
</tr>
</table>
</td>
</tr>

============================================================================================================================
Enjoy!