By Le Giang Anh on Sunday, 27 August 2017
Posted in General Issues
Replies 8
Likes 0
Views 529
Votes 0
Hi team,

I cannot manage to disable post date in Most Voted module. It seems that there is no setting for it?
https://www.screencast.com/t/IzA79KdZ6

Thanks,
Anh
Hm, it looks like there is a missing settings on the module. I will add them but temporarily, you may edit the file /modules/mod_easydiscuss_most_voted/tmpl/default.php and remove the codes below:

[gist]
<?php if ($params->get('showdate', 1)) { ?>
<div class="m-list__item">
<?php echo JText::sprintf('MOD_EASYDISCUSS_MOST_VOTED_POSTED_ON', ED::date($post->created)->format(ED::config()->get('layout_dateformat'))); ?>
</div>
<?php } ?>
[/gist]
·
Sunday, 27 August 2017 12:49
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark,

It works. However, the module work incorrectly caused it doesn't sort the post by vote:
https://www.screencast.com/t/947mTi9Hmo
I would be great if I can select some specific categories for this module instead of including all posts in the site.

Thanks,
Anh
·
Sunday, 27 August 2017 17:21
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Le Giang,

Hm, i think there are some confusions here. The "Most Voted" module actually displays the most number of votes a post has received. In this case, the first post, "Share us your comments and feedback" has 2 votes as well. One is a positive and the other is a negative.

When rendering the items on the module, it is rendering the amount of votes it has not the total number of votes it receives because not every vote is positive.
·
Sunday, 27 August 2017 20:45
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

I'm still confused. The goal of this module is ordering the post by the most number of the post.
So why I have this order?

Btw, Is there any option to allow the positive vote only?

Thanks,
Anh
·
Monday, 18 September 2017 10:54
·
0 Likes
·
0 Votes
·
0 Comments
·
Currently that was not possible to configure from the module setting, but you can try add following code in this file location and see how it goes?

JoomlaFolder/administrator/components/com_easydiscuss/models/posts.php

// LINE 3226 until 3289
public function getMostVoted($limit, $options = array())
{
$count = isset($limit) ? $limit : 10;

$includeReplies = isset($options['includeReplies']) ? $options['includeReplies'] : null;

$db = ED::db();

$queryExclude = '';
$excludeCats = ED::getPrivateCategories();

if (!empty($excludeCats)) {
$queryExclude .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
}

// posts
$query = 'select a.`isresolve`, a.`id`, a.`user_id`, a.`user_type`, a.`poster_name`, a.`title`, a.`id` as `parent_id`, a.category_id,';
$query .= ' (select count(1) from `#__discuss_votes` as b1 where b1.`post_id` = a.`id`) as `VotedCnt`, count( c.id ) as `num_replies`';
$query .= ' from `#__discuss_posts` as a ';
$query .= ' left join `#__discuss_posts` as c on a.`id` = c.`parent_id`';
$query .= ' and c.`published` = 1';
$query .= ' inner join `#__discuss_votes` as b on a.`id` = b.`post_id`';
$query .= ' where a.`parent_id` = 0';
$query .= ' and a.`published` = 1';

if (!empty($excludeCats)) {
$query .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
}

$query .= ' group by a.`id`';

// union both posts and replies
$query .= ' union ';

// replies
$query .= ' select c.`isresolve`, a.`id`, a.`user_id`, a.`user_type`, a.`poster_name`, a.`title`, a.`parent_id`, c.category_id, ';
$query .= ' count( b.id ) as `VotedCnt`, 0 as `num_replies`';
$query .= ' from `#__discuss_posts` as a';
$query .= ' inner join `#__discuss_posts` as c on a.`parent_id` = c.`id`';
$query .= ' inner join `#__discuss_votes` as b on a.`id` = b.`post_id`';
$query .= ' where a.`published` = 1';
$query .= ' and c.`published` = 1';

if (!empty($excludeCats)) {
$query .= ' and c.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
}

if (!$includeReplies) {
$query .= ' and a.`parent_id` = 0';
}

$query .= ' group by a.`id`';

// ordring
$query .= ' order by VotedCnt desc';

if ($count > 0)
$query .= ' limit ' . $count ;

$db->setQuery($query);
$posts = $db->loadObjectList();

return $posts;
}



Replace with :

public function getMostVoted($limit, $options = array())
{
$count = isset($limit) ? $limit : 10;

$includeReplies = isset($options['includeReplies']) ? $options['includeReplies'] : null;

$db = ED::db();

$queryExclude = '';
$excludeCats = ED::getPrivateCategories();

if (!empty($excludeCats)) {
$queryExclude .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
}

// posts
$query = 'select a.`isresolve`, a.`id`, a.`user_id`, a.`user_type`, a.`poster_name`, a.`title`, a.`id` as `parent_id`, a.category_id,';
$query .= ' a.`sum_totalvote` as `VotedCnt`, count( c.id ) as `num_replies`';
$query .= ' from `#__discuss_posts` as a ';
$query .= ' left join `#__discuss_posts` as c on a.`id` = c.`parent_id`';
$query .= ' and c.`published` = 1';
$query .= ' inner join `#__discuss_votes` as b on a.`id` = b.`post_id`';
$query .= ' where a.`parent_id` = 0';
$query .= ' and a.`published` = 1';

if (!empty($excludeCats)) {
$query .= ' AND a.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
}

$query .= ' group by a.`id`';

// union both posts and replies
$query .= ' union ';

// replies
$query .= ' select c.`isresolve`, a.`id`, a.`user_id`, a.`user_type`, a.`poster_name`, a.`title`, a.`parent_id`, c.category_id, ';
$query .= ' a.`sum_totalvote` as `VotedCnt`, 0 as `num_replies`';
$query .= ' from `#__discuss_posts` as a';
$query .= ' inner join `#__discuss_posts` as c on a.`parent_id` = c.`id`';
$query .= ' inner join `#__discuss_votes` as b on a.`id` = b.`post_id`';
$query .= ' where a.`published` = 1';
$query .= ' and c.`published` = 1';

if (!empty($excludeCats)) {
$query .= ' and c.`category_id` NOT IN (' . implode(',', $excludeCats) . ')';
}

if (!$includeReplies) {
$query .= ' and a.`parent_id` = 0';
}

$query .= ' group by a.`id`';

// ordring
$query .= ' order by VotedCnt desc';

if ($count > 0)
$query .= ' limit ' . $count ;

$db->setQuery($query);
$posts = $db->loadObjectList();

return $posts;
}
·
Monday, 18 September 2017 16:57
·
0 Likes
·
0 Votes
·
0 Comments
·
It seems work correctly except I cannot specify the categories of the posts which will include in the module. Hope that you will fix and improve this module later.
·
Wednesday, 20 September 2017 10:10
·
0 Likes
·
0 Votes
·
0 Comments
·
perhaps you can request this feature into our forum here https://stackideas.com/forums/easydiscuss/feature-requests we will see if there a lot of user also requested this, we will definitely consider add this in the future.
·
Wednesday, 20 September 2017 10:43
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post