I modify two file to make this requirement works, but i do not think it is the best way to do this , hope someone can give a better way to support this feature
welcome to my website http://ostack.cn/ to see example page
1.“qa-include\db\selects.php" , change function qa_db_qs_selectspec from order by to rand
The modify de code as below:
function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null, $createip = null, $specialtype = false, $full = false, $count = null)
{
if ($specialtype == 'Q' || $specialtype == 'Q_QUEUED') {
$type = $specialtype;
} else {
$type = $specialtype ? 'Q_HIDDEN' : 'Q'; // for backwards compatibility
}
$count = isset($count) ? min($count, QA_DB_RETRIEVE_QS_AS) : QA_DB_RETRIEVE_QS_AS;
switch ($sort) {
case 'acount':
case 'flagcount':
case 'netvotes':
case 'views':
$sortsql = 'ORDER BY ^posts.' . $sort . ' DESC, ^posts.created DESC';
break;
case 'created':
case 'hotness':
//$sortsql = 'ORDER BY ^posts.' . $sort . ' DESC'; //before modify
$sortsql = 'and ^posts.postid >= (SELECT floor( RAND() * ((SELECT MAX(^posts.postid) FROM ^posts)-(SELECT MIN(^posts.postid) FROM ^posts)) + (SELECT MIN(^posts.postid) FROM ^posts)))';//after modify
break;
default:
qa_fatal_error('qa_db_qs_selectspec() called with illegal sort value');
break;
}
$selectspec = qa_db_posts_basic_selectspec($voteuserid, $full);
$selectspec['source'] .=
" JOIN (SELECT postid FROM ^posts WHERE " .
qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']) .
(isset($createip) ? "createip=UNHEX($) AND " : "") .
"type=$ " . $sortsql . " LIMIT #,#) y ON ^posts.postid=y.postid";
if (isset($createip)) {
$selectspec['arguments'][] = bin2hex(@inet_pton($createip));
}
array_push($selectspec['arguments'], $type, $start, $count);
$selectspec['sortdesc'] = $sort;
return $selectspec;
}
2.Change 'qa-include\app\page.php' , change the home page from 'pages/default.php' to 'pages/question.php'
function qa_get_request_content()
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$requestlower = strtolower(qa_request());
$requestparts = qa_request_parts();
$firstlower = strtolower($requestparts[0]);
$routing = qa_page_routing();
if(empty($requestlower)){
qa_set_template('questions');
$qa_content = require QA_INCLUDE_DIR . 'pages/questions.php';
} elseif(isset($routing[$requestlower])) {
qa_set_template($firstlower);
$qa_content = require QA_INCLUDE_DIR . $routing[$requestlower];
} elseif (isset($routing[$firstlower . '/'])) {
qa_set_template($firstlower);
$qa_content = require QA_INCLUDE_DIR . $routing[$firstlower . '/'];
} elseif (is_numeric($requestparts[0])) {
qa_set_template('question');
$qa_content = require QA_INCLUDE_DIR . 'pages/question.php';
} else {
qa_set_template(strlen($firstlower) ? $firstlower : 'qa'); // will be changed later
$qa_content = require QA_INCLUDE_DIR . 'pages/default.php'; // handles many other pages, including custom pages and page modules
}
if ($firstlower == 'admin') {
$_COOKIE['qa_admin_last'] = $requestlower; // for navigation tab now...
setcookie('qa_admin_last', $_COOKIE['qa_admin_last'], 0, '/', QA_COOKIE_DOMAIN, (bool)ini_get('session.cookie_secure'), true); // ...and in future
}
if (isset($qa_content))
qa_set_form_security_key();
return $qa_content;
}