Title: Previous And Next Thread Links v1.0

Author: Area51Mafia, John Briggs

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

Copyright:  2009 John Briggs. All rights reserved.

Compatability: XMB 1.9.8 SP3

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 At very Bottom 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: include/online.inc.php
=======================
==========
Find Code:
==========

            if (false !== strpos($url, 'action=attachment')) {

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

            // Previous And Next Thread Links 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 Thread Links Mod End

=======================================================================================================================================
=======
Step 3:
=======

===================
Edit File: viewthread.php
===================

==========
Find Code:
==========

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

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

// Previous And Next Threads Link Mod Begin
} elseif ($action == 'next') {
    $query = $db->query("SELECT t.tid as t_tid FROM ".X_PREFIX."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 ".X_PREFIX."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 Admin Panel -> Templates
==========================
====================
Edit Template: viewthread
====================

==========
Find Code:
==========

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

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

<tr class="category">
<td colspan="2">
<table width="100%" cellpadding="0" cellspacing="0">
<tr class="navtd">
<td 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 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!