Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter

Categories

In this Discussion

Who's Online 9

CurtisOdenTomKericgillettewykthreed +5 guests

Voting Addon : Default Sort

This discussion is related to the Voting addon.
Hi, I like this plugin a lot. Thanks.

I wondered if it's possible to set the default sort to by Date Added rather than by Votes. I like that you can sort by votes, but the problem is that we have conversations by threads with another plugin (replies to specific comments). What happens is that when the original comment gets voted (or liked), it moves to the top automatically, leaving it's conversation (replies) to be orphans.

Is there a way to default to sort by Date?

Thanks!

Comments

  • Posts: 298
    Yeah, it is simple.


    ***** voting.bak
    // No sort was specified so grab it from the user's preferences.
    $Sort = Gdn::Session()->GetPreference('Plugins.Voting.CommentSort', 'popular');
    } else {
    ***** CLASS.VOTING.PLUGIN.PHP
    // No sort was specified so grab it from the user's preferences.
    $Sort = Gdn::Session()->GetPreference('Plugins.Voting.CommentSort', 'date');
    } else {
    *****

    ***** voting.bak
    if (!in_array($Sort, array('popular', 'date')))
    $Sort = 'popular';
    self::$_CommentSort = $Sort;
    ***** CLASS.VOTING.PLUGIN.PHP
    if (!in_array($Sort, array('popular', 'date')))
    $Sort = 'date';
    self::$_CommentSort = $Sort;
    *****

  • Posts: 298
    Better solution will be to have special setting for each category in admin panel.
    As I need sorting to be specific to each category (as well as voting controls display in discussion).
  • Thanks, tester!
  • Posts: 27
    @tester13 do you have a solution for sorting by votes for each category by any chance? That would make the plugin suit my needs nicely. Thanks.
  • Posts: 1
    [EDIT]
    class.voting.plugin.php

    LINE 140

    From

    $CommentModel->OrderBy(array('coalesce(c.Score, 0) desc', 'c.CommentID'));

    To

    $CommentModel->OrderBy('c.DateInserted');

    That worked for me, so just sharing.
  • Posts: 36
    I made all above changes but Sort by still does not filter by Added Date. It defaults to Votes and filters by Votes. Added Date does not work at all.

    Please help.

    Thank you.
  • Like berdia, I'm also finding that filtering by Date Added isn't working. The link is triggering, the URL querystring updates to 'Sort=date', the page (or part thereof) seems to try to refresh... but the order stays exactly the same, and the 'Votes' tab stays active.

    I thought it might be something I'd done in my development theme, but the same thing happens when switching back to the default Vanilla theme.

    Anyone got any clues? Many thanks!
  • Would like to bump this as I'm having the same issue.

  • Posts: 1,586

    This is something I won't spend to much time testing as any changes I make to voting will be to remove the sort by votes altogether.

    Vanilla co-founder

  • Posts: 4

    Just comment out line 137-152 in class.voting.plugin.php

    It worked for me.

Sign In or Register to comment.