• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Lack of interest Swipe to next thread

Alfa1

Well-known member
#1
On most news websites that I visit its possible to swipe to the next article. It has become pretty common functionality. It would be handy if it were possible on xenforo as well.

Instead of having to go back to new post and then going to the next thread to go straight to the next thread by swiping.
 

Daniel Hood

Well-known member
#2
I believe next and previous functionality has been suggested before due to not knowing how you would determine the next thread. Would it be the most recently posted in, the most recently created after that one (thread id +1), most recent posted in the same node, etc
 

Alfa1

Well-known member
#3
Thats where admin settings come in. Just leave that part up to the admin to decide.
I would not have to think twice about how to set it, but I am sure different admins will have different preferences on this.
 

batpool52!

Well-known member
#6
I manged to make something that worked.

Under XenForo_Model_Thread i added this
PHP:
public function getPrevNexLink($threadId, $nodeId, $previous, array $fetchOptions = array())
    {
        /* https://xenforo.com/community/threads/swipe-to-next-thread.87581/ */
        $joinOptions = $this->prepareThreadFetchOptions($fetchOptions);

        if ($previous == false)
        {
            return $this->_getDb()->fetchRow('
            SELECT thread.*
                ' . $joinOptions['selectFields'] . '
            FROM xf_thread AS thread
            ' . $joinOptions['joinTables'] . '
            WHERE thread.thread_id = (SELECT MIN(thread.thread_id) FROM xf_thread AS thread WHERE thread.thread_id > ' . $threadId . ' AND thread.node_id = ' . $nodeId. ')
            AND thread.node_id = ' . $nodeId);
        }
        else
        {
            return $this->_getDb()->fetchRow('
            SELECT thread.*
                ' . $joinOptions['selectFields'] . '
            FROM xf_thread AS thread
            ' . $joinOptions['joinTables'] . '
            WHERE thread.thread_id = (SELECT MAX(thread.thread_id) FROM xf_thread AS thread WHERE thread.thread_id < ' . $threadId . ' AND thread.node_id = ' . $nodeId .')
            AND thread.node_id = ' . $nodeId);
        }
    }


Under XenForo_ControllerPublic_Thread, inside actionIndex function and under $viewParams i added this code
PHP:
'previousLink' => XenForo_Link::buildPublicLink('threads', $threadModel->getPrevNexLink($thread['thread_id'], $thread['node_id'], true)),
            'nextLink' => XenForo_Link::buildPublicLink('threads', $threadModel->getPrevNexLink($thread['thread_id'], $thread['node_id'], false)),
and it works fine if used under templates :)
 

RobinHood

Well-known member
#7
This would be really nice for the new posts link. I feel the default should be the next thread in the same new posts id list as that's how it currently works when you back out of a thread to the new posts page to move onto the next one.

If your in a thread having navigated to it by node, then the next thread would be the next one in the list however you had the node list ordered before you opened the thread.
 

Sheratan

Well-known member
#8
In IE and Chrome, swipe means back (or forward). I don't know about Firefox.

This is a great suggestion, but I'm afraid it will become problem.
 

rainmotorsports

Well-known member
#9
In IE and Chrome, swipe means back (or forward). I don't know about Firefox.

This is a great suggestion, but I'm afraid it will become problem.
On what platform? I'm swiping left to right across this whole thread and its doing nothing. A long time ago in chrome that would happen. Especially the tab change gestures. I get nothing on Chrome v39 and Android 5.

IE on a tablet I'm assuming would be your use case?