Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1.0k views
in Q2A Core by

Hi,

I’m working on a community where answers can come from both regular users and experts in the specific area and I want to make it clear when it is an expert, editor or regular user. My thought is just to make a different background color or make some icon on one of the sides so all I really need is to append some CSS CLASS tag to the regular class’.

E.g. when it is an admin that has answered, the CLASS could look something like this:

qa-a-list-item  hentry answer admin-answer

and for an expert something like this

qa-a-list-item  hentry answer expert-answer

and so on, and so on.

I’ve tried to make an override function in my ga-theme.php file with a_count($post) but I’m not sure how to check to see which type of user role it is and then append some class to the normal class attributes.

Hope someone could help me with this.
Thank you

Sincere
- Emil

1 Answer

0 votes
by

First, the function you should be overriding is a_list_item($a_item) to change the list of answers on a question page. For the user's level, assuming you're using a relatively recent version of Q2A, check $a_item['raw']['level'] for a numeric value, or $a_item['who']['level'] for a string representation. Either way, your overriding function can just add something to $a_item['classes'] then call the default function using qa_html_theme_base::a_list_item($a_item)

by
Thank you very much. The one I missed was the $a_item[item][item] code but instead of moving around in the template file. I just added an extra class in the qa-theme-base.php file, around line 1477:

$authorclass=strtolower(str_replace(' ', '-', @$a_item['who']['level']));

and then made sure that the super administrator has an hyphen in the name and made all to lower case.

Works perfect :-)

Thank you very much
by
hi Emil 'Bobo' Devantie, can you post the complete code pls
...