Like the guide in this post (
http://www.question2answer.org/qa/626/most-popular-questions-tab#a630) I tried to create a best question feature.
The folllowing sqlstatement works (SQL Client only) and all question are sorted by up and downvotes.
But in my q2a webpage the results are not (!) sorted by up and downvotes.
Any Ideas?
qa-db-selects.php
function qa_db_best_qs_selectspec($voteuserid, $start, $categoryslug=null, $createip=null, $hidden=false, $fullanswers=false, $count=QA_DB_RETRIEVE_QS_AS)
{
$selectspec=qa_db_posts_basic_selectspec($voteuserid, null);
$selectspec['source'].=" JOIN (SELECT postid FROM ^posts WHERE ".(isset($categoryslug) ? "categoryid=(SELECT categoryid FROM ^categories WHERE tags=$ LIMIT 1) AND " : "")."type=$ ORDER BY CONVERT(^posts.upvotes, SIGNED) - CONVERT(^posts.downvotes, SIGNED) DESC LIMIT #,#) y ON ^posts.postid=y.postid";
if (isset($categoryslug))
$selectspec['arguments'][]=$categoryslug;
array_push($selectspec['arguments'], $hidden ? 'Q_HIDDEN' : 'Q', $start, $count);
$selectspec['sortdesc']='created';
return $selectspec;
}
qa-page-home.php
case 'bestquestions':
$categoryqcount=true;
if (!qa_home_load_ifcategory(
'page_size_qs', 'feed_for_questions', 'cache_qcount', 'main/most_answered_qs_title', 'main/no_questions_found', 'main/most_answered_qs_title', 'main/no_questions_found',
qa_db_best_qs_selectspec($qa_login_userid, $qa_start, $categoryslug)
))
return $qa_content;
if (isset($categoryid)) {
$count=$categories[$categoryid]['qcount'];
$suggest=qa_html_suggest_qs_tags(qa_using_tags());
} else
$suggest=qa_html_suggest_ask($categoryid);
break;