Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
237 views
in Q2A Core by
Here what  I want to do is that whenever the admin post an answer then the answer's  background should be in different color from other answers.So that it is easy to identify that this answer is posted by Admin.

I know this would require  code changes but don't know How to do that

1 Answer

+2 votes
by
selected by
 
Best answer

If you want to change background of the Entire Answer Node:

function a_list_item($a_item)

{$bgcolor = "";

$level = $a_item['raw']['level'];
switch ($level) {
 
//Change colour values below
 
case QA_USER_LEVEL_SUPER:
$bgcolor = "#AAAAAA"; break;
case QA_USER_LEVEL_ADMIN:
$bgcolor = "#BBBBBB"; break;
case QA_USER_LEVEL_MODERATOR:
$bgcolor = "#CCCCCC"; break;
case QA_USER_LEVEL_EDITOR:
$bgcolor = "#DDDDDD"; break;
case QA_USER_LEVEL_EXPERT:
$bgcolor = "#EEEEEE"; break;
}
if ($bgcolor == "") {
qa_html_theme_base::a_list_item($a_item);
} else {
$this->output('<div style="background-color:'.$bgcolor.' !important;">');
qa_html_theme_base::a_list_item($a_item);
$this->output('</div>');
}
}
 
function head_custom() {
qa_html_theme_base::head_custom();
$this->output('<style>.qa-a-list-item {background-color:initial;}</style>');
}
 
If you want to change background of just the Answer content:
 
function a_item_content($a_item)
{
$bgcolor = "";
$level = $a_item['raw']['level'];
switch ($level) {
case QA_USER_LEVEL_SUPER:
$bgcolor = "#AAAAAA"; break;
case QA_USER_LEVEL_ADMIN:
$bgcolor = "#BBBBBB"; break;
case QA_USER_LEVEL_MODERATOR:
$bgcolor = "#CCCCCC"; break;
case QA_USER_LEVEL_EDITOR:
$bgcolor = "#DDDDDD"; break;
case QA_USER_LEVEL_EXPERT:
$bgcolor = "#EEEEEE"; break;
}
if ($bgcolor == "") {
qa_html_theme_base::a_item_content($a_item);
} else {
$this->output('<div style="padding: 2px; background-color:'.$bgcolor.'">');
qa_html_theme_base::a_item_content($a_item);
$this->output('</div>');
}
}
by
Thanks man. It worked great exactly what I was looking for.
...