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 navigating to the next and previous threads.

Copyright:  2009 John Briggs. All rights reserved.

Compatibility: XMB 1.9.8 SP4

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 v3 License. A copy is provided with this software package.

Author Note: This modification is developed and released for use with XMB 1.9.8 SP4 which is provided by XMBGarage.com.

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

            if (false !== strpos($url, 'action=attachment')) {
                $url = substr($url, 0, strpos($url, '?'));
                $url .= '?tid='.$tid;
            }

===============
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 Thread Links Mod Begin
} else if ($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);
} else if ($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 Thread Links 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="navtd">
<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!