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

Likes for current page

Mythotical

Well-known member
#1
I'm trying to pull the likes for the current page of a thread that a user is currently viewing. The code I have so far is this:

PHP:
    private function getPagePosts()
    {
        $db = XenForo_Application::getDb();
        $options = XenForo_Application::get('options');
        
        return $db->fetchAll("
            SELECT *
            FROM xf_post AS post
            LEFT JOIN xf_user AS user ON (user.user_id = post.user_id)
            WHERE
                post.thread_id = ? AND
                post.likes > 0
            ORDER BY
                post.post_date DESC
            ", array( $this->_params['thread']['thread_id'] ));
    }
I'm doing this in a ViewPublic file for Thread.php

Thanks
 

Mythotical

Well-known member
#3
Attempting to use:
PHP:
$this->_params['page']
Returns an array, so put it in an array() it comes back with an error: An exception occurred: Mysqli prepare error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 5 OFFSET 1'

So not sure where to go now.
 

Mythotical

Well-known member
#4
Ok so I have it working, the problem now is that it displays results for page-2 instead of the current page. How do I get this to work with showing me current page results only?