Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Is it possible to show on main page if the question has a best answer?

+8 votes
324 views
asked Nov 10, 2010 in Q2A Core by Tenac
Is it possible to show if a question has a best answer on index pages? for example it shows if it has answers posted and has a class of "qa-q-item-what" but i want to show an icon if the question has a best answer only.

1 Answer

+2 votes
answered Nov 10, 2010 by gidgreen
edited Nov 10, 2010 by gidgreen
 
Best answer

It's not immediately possible and you'd need to do a couple of small PHP things.

First, in qa-db-selects.php, move the following line out of the if (...) it's within:

$selectspec['columns'][]='^posts.selchildid';

(This will be done in the next release of Q2A anyway.)

Second, create an advanced theme, and override the appropriate function, depending on where you want the icon. Perhaps post_meta_what() in which case your copy of the function should include the following code:

if (isset($post['raw']['selchildid'])) {

$this->output('HTML CODE TO DISPLAY YOUR ICON');

}

commented Nov 10, 2010 by Tenac
It Worked perfectly. Thank you
commented Mar 14, 2013 by q2apro
From 1.5.4 on there is a CSS class .qa-a-count-selected added to the answer count field.

You could use CSS3 to add "best answer selected" to the answer field using:

.qa-a-count-selected:afte.qa-q-list-item {
position:relative;
}
.qa-a-count-selected:after {
font-size:10px;
color:#FFA540;
content:"Best selected";
position:absolute;
left:153px;
top:95px;
width:35px;
}

OR as stated in the question to change the background color:

.qa-a-count-selected {
  background:#FFCCCC;
}
...