Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Voting Addon : Default Sort

edited February 2011 in Vanilla 2.0 - 2.8
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

  • edited February 2011
    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; *****
  • 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!
  • @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.
  • edited May 2011
    [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.
  • 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.

  • ToddTodd Vanilla Staff

    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.

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

    It worked for me.

  • Any DEV that can confirm that @BboyHavoc's idea to comment out line 137-152 in class.voting.plugin.php is not making any trouble?

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • Mmh, all of the above solutions don't work. Did no one manage to do this? Thanx for help

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • Hi guys,

    This solves the problem :

    "On line 174 of the "class.voting.plugin.php" change "popular" to "date", this should change it for comments, not sure about anything else."

    http://vanillaforums.org/discussion/20938/change-vote-plugin-sorting-default-to-date-instead-of-votes

  • In 2014 script changes again

    a) In line 137 Must be defaut insted of 140

    then

    b) In line 156 between 164

    All date's must be popular, all popular must be date.

    Two steps work for me.

Sign In or Register to comment.