Topic: how about add button next or previous topic ?

i think this optional will make easy user read topic without back to viewforum or index to see other topics big_smile
hwo to create coding like this?
http://i.giphy.com/lKXEBR8m1jWso.gif

sorry my BAD english T___T
Have a nice day >.<
(^____^)v

2 (edited by sempai 2016-08-11 10:16)

Re: how about add button next or previous topic ?

Look here: link

3 (edited by PanBB.Ru 2016-08-12 10:37)

Re: how about add button next or previous topic ?

Разберешься?

    $bquery = array(
        'SELECT'    => 'MIN(bt.id), bt.subject',
        'FROM'        => 'topics AS bt',
        'WHERE'        => 'bt.id>'.$id,
    );
    $bresult = $forum_db->query_build($bquery) or error(__FILE__, __LINE__);
    $back = $forum_db->fetch_assoc($bresult);
    
    if(isset($back['MIN(bt.id)']))
        $tback = '<a href="'.forum_link($forum_url['topic'], array($back['MIN(bt.id)'], sef_friendly($back['subject']))).'">'.$back['subject'].'</a>';
    
    $nquery = array(
        'SELECT'    => 'MAX(nt.id), nt.subject',
        'FROM'        => 'topics AS nt',
        'WHERE'        => 'nt.id<'.$id,
    );
    $nresult = $forum_db->query_build($nquery) or error(__FILE__, __LINE__);
    $next = $forum_db->fetch_assoc($nresult);
    
    if(isset($next['MAX(nt.id)']))
        $tnext = '<a href="'.forum_link($forum_url['topic'], array($next['MAX(nt.id)'], sef_friendly($next['subject']))).'">'.$next['subject'].'</a>';
        
    echo $tback;
    echo $tnext;

will you understand?

Or second embodiment:

    $query = array(
        'SELECT'    => 't.id, t.subject',
        'FROM'        => 'topics AS t',
        'WHERE'        => 't.forum_id='.$cur_topic['forum_id']
    );
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    
    $back = array();
    $next = array();
    while($topics = $forum_db->fetch_assoc($result))
    {
        if($topics['id'] < $id)
            $back[$topics['id']] = $topics['subject'];
        else if ($topics['id'] > $id)
            $next[$topics['id']] = $topics['subject'];
    }
    
    $back_id = max(array_keys($back));
    $back_subject = $back[$back_id];
    
    $next_id = min(array_keys($next));
    $next_subject = $next[$next_id];
    
    $tback = !empty($back_id) ? '<a href="'.forum_link($forum_url['topic'], array($back_id, sef_friendly($back_subject))).'" title="Old topic">'.$back_subject.'&nbsp;&#9668;&#9668;&nbsp;</a>' : '';
    
    $tnext = !empty($next_id) ? '<a href="'.forum_link($forum_url['topic'], array($next_id, sef_friendly($next_subject))).'" title="Next topic">&nbsp;&#9658;&#9658;&nbsp;'.$next_subject.'</a>' : '';
    

Re: how about add button next or previous topic ?

PanBB.Ru wrote:

Разберешься?

will you understand?

Or second embodiment:

No.. where i must place this?

sorry my BAD english T___T
Have a nice day >.<
(^____^)v

Re: how about add button next or previous topic ?

well, well... then it is better use the extension. see above.

6 (edited by kerlinrao 2016-09-28 21:13)

Re: how about add button next or previous topic ?

PanBB.Ru wrote:

Разберешься?

    $bquery = array(
        'SELECT'    => 'MIN(bt.id), bt.subject',
        'FROM'        => 'topics AS bt',
        'WHERE'        => 'bt.id>'.$id,
    );
    $bresult = $forum_db->query_build($bquery) or error(__FILE__, __LINE__);
    $back = $forum_db->fetch_assoc($bresult);
    
    if(isset($back['MIN(bt.id)']))
        $tback = '<a href="'.forum_link($forum_url['topic'], array($back['MIN(bt.id)'], sef_friendly($back['subject']))).'">'.$back['subject'].'</a>';
    
    $nquery = array(
        'SELECT'    => 'MAX(nt.id), nt.subject',
        'FROM'        => 'topics AS nt',
        'WHERE'        => 'nt.id<'.$id,
    );
    $nresult = $forum_db->query_build($nquery) or error(__FILE__, __LINE__);
    $next = $forum_db->fetch_assoc($nresult);
    
    if(isset($next['MAX(nt.id)']))
        $tnext = '<a href="'.forum_link($forum_url['topic'], array($next['MAX(nt.id)'], sef_friendly($next['subject']))).'">'.$next['subject'].'</a>';
        
    echo $tback;
    echo $tnext;

will you understand?

Or second embodiment:

    $query = array(
        'SELECT'    => 't.id, t.subject',
        'FROM'        => 'topics AS t',
        'WHERE'        => 't.forum_id='.$cur_topic['forum_id']
    );
    $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
    
    $back = array();
    $next = array();
    while($topics = $forum_db->fetch_assoc($result))
    {
        if($topics['id'] < $id)
            $back[$topics['id']] = $topics['subject'];
        else if ($topics['id'] > $id)
            $next[$topics['id']] = $topics['subject'];
    }
    
    $back_id = max(array_keys($back));
    $back_subject = $back[$back_id];
    
    $next_id = min(array_keys($next));
    $next_subject = $next[$next_id];
    
    $tback = !empty($back_id) ? '<a href="'.forum_link($forum_url['topic'], array($back_id, sef_friendly($back_subject))).'" title="Old topic">'.$back_subject.'&nbsp;&#9668;&#9668;&nbsp;</a>' : '';
    
    $tnext = !empty($next_id) ? '<a href="'.forum_link($forum_url['topic'], array($next_id, sef_friendly($next_subject))).'" title="Next topic">&nbsp;&#9658;&#9658;&nbsp;'.$next_subject.'</a>' : '';
    

I have tried it but i messed up at then end. Is there any alternate route to do so.....!
Infantigo

Re: how about add button next or previous topic ?

http://punbb.ru/topic6223-reliz-linker.html