Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
336 views
in Q2A Core by
How can I get the question tab to sort itself by number of votes, rather than how recently it was created?  I'm happy to play around in the php files as I have been doing, but am quite new to it!

Thanks

1 Answer

0 votes
by
It will be difficult to sort by votes globally, since this requires modifications to the database schema. However it is relatively easy to sort by votes within the page - add the following lines before the qa_content_prepare() statement in qa-page-home.php:

if ($qa_template=='questions') {
  foreach ($questions as $key => $question)
    $questions[$key]['netvotes']=$question['upvotes']-$question['downvotes'];

  qa_sort_by($questions, 'netvotes');
  $questions=array_reverse($questions, true);
}

An integrated (database-wide) implementation of this is on the roadmap.
by
in version 1.5.1 there is no file called qa-page-home.php

Sorting by votes works for the entire database, but not for individual categories
by
You can allow sorting by votes for individual categories by modifying the QA_ALLOW_UNINDEXED_QUERIES setting in qa-config.php.
...