HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Search
-
How to sort discussions based on the discussion table column
Hi I want to sort the discussions based on table column Score, my discussion table has Score entries when I check this url somesite/discussions?sort=score nothing has changed. Any Ideas why this is not working? In my plugin I have this code public function discussionModel_beforeGet_handler($sender,$args){ $sender->addSort(… -
Re: How to sort discussions based on the discussion table column
Read this entire thread. Some very very very goods inside https://open.vanillaforums.com/discussion/32730/any-example-of-using-the-new-sort-filter-module If you get stuck, do a $_GET (the vanilla f. way), match the key "score" and run this code Gdn::sql()->orderBy('score', 'desc'); //make the desc a variable if you want -
Re: How to sort discussions based on the discussion table column
@donshakespeare I get the query string from the url and use it with Gdn::sql()->orderBy in discussionModel_beforeGet_handler and discussionModel_BeforeGetCount_handler $sortValue = Gdn::request()->get('sort'); if($sortValue == 'some_sort_value'){ Gdn::sql()->orderBy('some_discussion_column', 'desc'); } Then I update the… -
Re: How to sort discussions based on the discussion table column
@donshakespeare good to have you here 😀 @rloyola sort by Score, desc is a a built in sort. You can find this in the DiscussionModel: protected static $allowedSorts = [ 'hot' => ['key' => 'hot', 'name' => 'Hot', 'orderBy' => ['DateLastComment' => 'desc']], 'top' => ['key' => 'top', 'name' => 'Top', 'orderBy' => ['Score' =>…
4 results