Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
843 views
in Q2A Core by
Currently q2a shows new answers on bottom. How can i show new answers on top instead?

There is a discussion but i could not find any solution.

http://www.question2answer.org/qa/14953/question-view-page-showing-recent-answers-first-answers-last?show=14953#q14953

Thanks for your help.
Q2A version: Latest

2 Answers

+2 votes
by

Probably, this is an answer.

qa-include/pages/question.php (In case of V1.7.4,  L283-L290)

Before:

if (qa_opt('sort_answers_by')=='votes') {
    foreach ($answers as $answerid => $answer)
        $answers[$answerid]['sortvotes']=$answer['downvotes']-$answer['upvotes'];

    qa_sort_by($answers, 'sortvotes', 'created');

} else
    qa_sort_by($answers, 'created');

After:

if (qa_opt('sort_answers_by')=='votes') {
    foreach ($answers as $answerid => $answer)
        $answers[$answerid]['sortvotes']=$answer['downvotes']-$answer['upvotes'];

    qa_sort_by($answers, 'sortvotes', 'created');

} else {
    qa_sort_by($answers, 'created');
    $answers = array_reverse($answers, true);
}

Note: 

  • There is no solution other than core hacking.
  • This is a partial (not fundamental) solution.
by
@sama55,

Thank you for the code. I tried this solution but it does not filter recent answers on top.

I think it could be simple solution, just to reverse the order of answers, from top to bottom and bottom to top. I wish we had that option.
by
I confirmed that the code above works correctly. Are your options below correct?
"Admin" > "Viewing" >"Sort answers by" <=== You should set 'Time'.
"Admin" > "Viewing" >"Move selected answer to the top" <=== In case of ON, selected answer is placed on the top.
by
I agree @sama55. Your updated code works perfectly.  Thank you for clarifying it.
0 votes
by
It's very simple. Make homepage
" Questions " instead of "Q&A".
...