Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
612 views
in Q2A Core by
I want to listed only answered questions on the main page of my website. How can I do that?
by
Maybe better - new page type "Answered - Recent questions with answers". (Then follow the question http://www.question2answer.org/qa/9787/how-to-change-default-root-link-of-q2a-script ).

2 Answers

0 votes
by

You need to make 2 changes:

1) In file qa-include/qa-db-selects.php (Replace function qa_db_unanswered_qs_selectspec with the following):

 

function qa_db_unanswered_qs_selectspec($voteuserid, $start, $categoryslugs=null, $hidden=false, $full=false, $count=QA_DB_RETRIEVE_QS_AS, $answeredOnly=false)
/*
Return the selectspec to retrieve $count recent unanswered ($hidden or not) questions,
starting from offset $start, restricted to the category for $categoryslugs (if not null),
with the corresponding vote made by $voteuserid (if not null) and including $full content or not
*/
{
$selectspec=qa_db_posts_basic_selectspec($voteuserid, $full);
 
$acount = ($answeredOnly ? "acount>0" : "acount=0");
$selectspec['source'].=" JOIN (SELECT postid FROM ^posts WHERE ".qa_db_categoryslugs_sql($categoryslugs)."type=$ AND ".$acount." ORDER BY ^posts.created DESC LIMIT #,#) y ON ^posts.postid=y.postid";
 
array_push($selectspec['arguments'], $hidden ? 'Q_HIDDEN' : 'Q', $start, $count);
 
$selectspec['sortdesc']='created';
 
return $selectspec;
}
 
2) In file qa-include/qa-page-unanswered.php:
Replace this line:
qa_db_unanswered_qs_selectspec($qa_login_userid, $qa_start, null, false, false, QA_DB_RETRIEVE_QS_AS)
With my code :
qa_db_unanswered_qs_selectspec($qa_login_userid, $qa_start, null, false, false, QA_DB_RETRIEVE_QS_AS, true)
 
 
NOTE:
In this way you will make Unanswered questions act as Answered questions. To make both Unanswered and Answered pages work. You need to do some more simple core changes.
+1 vote
by

No need to edit the core.  Make a custom layer, or edit the theme file.  In function q_list_item($question), put this as the first line:

if(!$question['raw']['acount']) return;

by
This makes all of my questions disappear
...