Robust
Well-known member
Having a 'lil problem:
I extend XenForo_Model_Post, and have this code:
It does, however, seem to cause incompatibilities with other add-ons - any solutions?
I know I could narrow down the query to only work in the forums my add-on is enabled in (it's forum-enabled based), however, I can't fetch the forum the post is in at this level.
What this does, essentially, is finds out if the XenForo_Visitor has voted on a piece of content. If a value for vote_date exists, it means they have voted, otherwise they haven't (this decides whether to show the vote/unvote button).
I extend XenForo_Model_Post, and have this code:
Code:
public function preparePostJoinOptions(array $fetchOptions)
{
$return = parent::preparePostJoinOptions($fetchOptions);
$db = $this->_getDb();
$return['selectFields'] .= ',
ba_votes.vote_date';
$return['joinTables'] .= '
LEFT JOIN ba_votes
ON (ba_votes.thread_id = post.thread_id
AND ba_votes.post_id = post.post_id
AND ba_votes.vote_user_id = ' . $db->quote(XenForo_Visitor::getUserId()) . ')';
return $return;
}
It does, however, seem to cause incompatibilities with other add-ons - any solutions?
I know I could narrow down the query to only work in the forums my add-on is enabled in (it's forum-enabled based), however, I can't fetch the forum the post is in at this level.
What this does, essentially, is finds out if the XenForo_Visitor has voted on a piece of content. If a value for vote_date exists, it means they have voted, otherwise they haven't (this decides whether to show the vote/unvote button).