Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
599 views
in Q2A Core by
I'm struggling to add the user's avatar (or default if they have that selected) alongside the question slist. Adding:

$this->post_avatar($question, 'qa-q-item');

..inside the function q_list_item($question) doesn't appear to work :-/
by
When inside the question ($q-view), it displays the default avatar for the user who asked the question. How can I get this same functionality on the questions list?

1 Answer

0 votes
by

I did this before, but users complained it was cluttering up the lists... I think I just called the function qa_get_user_avatar_html() from qa-app-users.php (you need to include that file, I think)

by
Hm, not sure how to do this inside the $q-list function in the theme override? Surely you can't include the qa-app-users.php inside the theme?
If I list all variables on the $q-view page, [raw][avatar] is available and shows default avatar if user not got one selected.
Which file and how would I need to "hack" to get the $q-list-item to have same?
by
sure, why not?  I do it :)

    require_once QA_INCLUDE_DIR.'qa-app-users.php';
    $avatar = qa_get_user_avatar_html(<allsortsofarguments>);

I don't know why the q-list-item doesn't have avatars...
by
Thanks, what arguments would i need and how would i get the required user info inside $q-list-item?

function qa_get_user_avatar_html($flags, $email, $handle, $blobid, $width, $height, $size, $padding=false)

$avatar = qa_get_user_avatar_html($email=?,$handle=?);
by
edited by
look and see where else the function is called and how it is handled... the code's all there...

"The Linux philosophy is 'Laugh in the face of danger'. Oops. Wrong One. 'Do it yourself'. Yes, that's it."

-- Linus Torvalds
by
edited by
Yes! I'm fairly new to php/linux and find the huge number of files and interconnecting bits and pieces all over the place in this (lovely) script confusing!

Anyways, ssh came to the rescue. Grep. Found the qa-page -user file:

$avatar = qa_get_user_avatar_html($question['raw']['flags'], $question['raw']['email'], $question['raw']['handle'],$question['raw']['avatarblobid'], '50', '50', qa_opt('avatar_profile_size'));
           
Now works! Thanks for your help. On to the next problem lol
by
You're welcome... I was going to say, grep -R is your friend :)
by
Actually one more thing along same theme, trying to get post user points title.

Ive included qa-app-format.php and tracked down this:

qa_get_points_title_html($userpoints, $pointstitle)

I can get the qlistitem's userpoints from $question['raw']['points'], but the pointstitle seems to be an array and i'm not sure how to grab that?
by
Did some digging for you, looks like there are two options:

qa_get_points_to_titles()

or

global $qa_points_title_cache;

The latter is probably the way to go.  Remember, grep is your friend.
by
Recon solved doing this:

            require_once QA_INCLUDE_DIR.'qa-app-format.php';
            require_once QA_INCLUDE_DIR.'qa-app-options.php';
            $authortitle = qa_get_points_title_html($question['raw']['points'], qa_get_points_to_titles());

Thanks again! :)
by
Welcome.  I think if you use:

global $qa_points_title_cache;
$authortitle = qa_get_points_title_html($question['raw']['points'], $qa_points_title_cache);

you will save resources, since there is then no need to call external files.
by
Ahh I see. Big improvement!!
...