Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Anyone have Prev/Next Thread / Forum plugin?


fel64
Member

@fel64

Ahh, that’ll teach me to remember the difference between get_bbpress_thing() and bbpress_thing(). >_< Sorry.

Replace the code in there now with this.

Set the last parameter to true if you want it to return an array of information. To use this you would use code like this:

<?php $mytopicnavarray = feltopicnav( '', '', ' ', true, true );
echo '<a href="' . $mytopicnavarray['next']['link'] . '">Click here to go to the next topic!</a>'; ?>

Use <?php felforumnav(); ?> to get the forum navigation in a similar way to the topic navigation. It’s just a simple wrapper for what feltopicnav does, but it’s a bit easier to see what it’s supposed to do. Check the code for possible parameters.

I won’t submit this as a proper plugin because the code is awkward. Maybe sometime I’ll recode it or someone else will. :)

<?php
/*
Plugin Name: Topic Navs;
Plugin URI:
Description: Put <?php feltopicnav(); ?> in a topic template to show links to the previous and next topics, and put in <?php felforumnav(); ?> to get basic next/previous forum navigation. More parameters such as $infoonly available.
Author: fel64
Version: 0.7
Author URI: http://www.loinhead.net/
*/

function feltopicnav( $nexttext = '', $prevtext = '', $betweentext = ' ', $lastpost = true, $infoonly = false, $forumnav = false; )
{
global $topic_id;
$nexttopic = $topic_id + 1;
$prevtopic = $topic_id - 1;
global $forum_id;
$nextforum = $forum_id + 1;
$prevforum = $forum_id - 1;
if( !$nexttext )
if( !$forumnav ) {
$nexttext = get_topic_title( $nexttopic );
} else {
$nexttext = get_forum_name( $nextforum );
}
if( !$prevtext )
if( !$forumnav ) {
$prevtext = get_topic_title( $prevtopic );
} else {
$prevtext = get_forum_name( $prevforum );
}
$prevtext = get_topic_title( $prevtopic );
if( $lastpost ) {
$nextlink = get_topic_last_post_link( $nexttopic );
$prevlink = get_topic_last_post_link( $prevtopic );
} else {
if( !$forumnav ) {
$nextlink = get_topic_link( $nexttopic );
$prevlink = get_topic_link( $prevtopic );
} else {
$nextlink = get_forum_link( $nextforum );
$prevlink = get_forum_link( $prevforum );
}
}
if( $infoonly ) {
$topicnavinfo['next']['title'] = $nexttext;
$topicnavinfo['next']['link'] = $nextlink;
$topicnavinfo['prev']['title'] = $prevtext;
$topicnavinfo['prev']['link'] = $prevlink;
return $topicnavinfo;
} else {
echo '<a href="' . $prevlink . '"> &laquo; ' . $prevtext . '</a>' . $betweentext . '<a href="' . $nextlink . '">' . $nexttext . ' &raquo; </a>';
}
}

function felforumnav( $nexttext = '', $prevtext = '', $betweentext = ' ', $infoonly = false )
{
$fni = feltopicnav( $nexttext, $prevtext, $betweentext, false, true, true );
if( $infoonly ) {
return $fni;
} else
echo '<a href="' . $fni['prev']['link'] . '"> &laquo; ' . $fni['prev']['title'] . '</a>' . $betweentext . '<a href="' . $fni['next']['link'] . '"> &laquo; ' . $fni['next']['title'] . '</a>';
}
}
?>

Skip to toolbar