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.
Sorting discussions by votes
tmilovan
New
Comments
Find:
DiscussionModel->SQL->OrderBy('d.CountViews', 'desc');
(for me it was line 458)
Comment out and insert:
$DiscussionModel->SQL->OrderBy('COALESCE(d.Score,0)', 'desc');
Now you will have it sorted by vote.
Thanks, @realrasengan. That worked like a charm.
Followup: is there a way to constrain the date range for this view of popular discussions? I'd like to avoid having a static list of "all-time" popular discussions, and opt instead for a 30-day range.
@charliepratt add a where statement that compares
DateUpdated
to 30 days ago. Something like:Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight just tried this option and it returns no results.
You probably have to add a
d.
in front of the field.I can't test against Vanilla right now.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
try this:
->Where('d.DateUpdated >=', Gdn_Format::ToDateTime(strtotime('-30 days')));
but be forewarned your pager will still show additional pages where discussion topics will be blank because of the where restriction, but it will do the job.
Todd presented this tip for me months ago for a different table.
I suspect you could change the pager to reflect the proper count based on number of discussions retrieved, but that I'll leave up to you to research .
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
or this
depending on what you want to do based on what.
for a 30-day range of what?
30 days since last comment maybe better.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
@peregrine - this did what I needed. Thanks to @hgtonight for the alley oop.
I am sorry but can you tell me in which file I have to edit? You all seem to know which file you are talking about, but i don´t =D
@dominikl Pretty sure this is fixed in the latest version of the Voting addon: https://github.com/vanilla/addons/blob/301a22488311806e0763e1f855473f04c3e06623/plugins/Voting/class.voting.plugin.php#L149
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.