DL6
Well-known member
Hi, I'm working on a new widget that shows the most liked posts of current day/week/month/year, this test works well
but this makes 2 queries for each option, when I try with something like this I get an error
"Parse error: syntax error, unexpected '%' in src\addons\EMD\TemplateEdits\XF\Widget\MostLikedPosts.php on line 54"
is there another way to do this?
PHP:
$postIds = $this->db()->fetchAllColumn("
SELECT post_id
FROM xf_post
WHERE (DATE_FORMAT(FROM_UNIXTIME(post_date),'%Y-%m-%d')) = CURDATE()
AND message_state = 'visible'
AND likes > 0
ORDER BY likes DESC
LIMIT 20
");
$postFinder = $this->finder('XF:Post');
$postFinder
->with(['Thread.Forum.Node.Permissions|' . $visitor->permission_combination_id, 'User'])
->where('post_id', $postIds)
->setDefaultOrder('likes', 'DESC')
->limit(max($limit * 2, 10));
PHP:
$postFinder->where('(DATE_FORMAT(FROM_UNIXTIME(post_date),'%Y-%m-%d'))','CURDATE()');
is there another way to do this?
Last edited: