Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
in Q2A Core by
First, thanks for the new release and the inclusion of avatars for question lists !!!

The curl feature for fb login seems to work as well so far. The fequently errors I had are gone at least.


Last missing thing (out of my view) would be the option to add the users avatar and title to the top users list.

On the users page it is called, can this be done for the topusers in sidebar as well ?

Thank You, and I am still impressed of the excellent work You are doing, the script is excellent and bugs found by the community have been allways small and fixed very fast,

related to an answer for: Problem with function qa_db_single_select

1 Answer

0 votes
Best answer
Use function qa_get_user_avatar_html(...) to get the HTML for a user's avatar. The first six parameters to this function should be the appropriate database columns, and the seventh is the size (in pixels) that the avatar should be displayed. You can see a simple example of its use in qa-page-user.php.

As for the user titles, use function qa_get_points_title_html($points, qa_get_points_to_titles()) to get the HTML for a user's title, where $points is the number of points the user has.
First add this to Your sidepanel function,

//    TOPUSERS fucntion call begin
//    TOPUSERS fucntion call end

After the sidepanel function add this function.

//    TOPUSERS Function --- Begin

function topusers()

$newusersarray=( array_slice($users, 0, 10 ) );

$this->output('<DIV CLASS="qa-sidepanel-box-oben">');
   $this->output('<DIV CLASS="sidepanel-box-two">');
                echo "Most active users";
$this->output('</h2>', '');

$this->output('<ul CLASS="qa-sidebar-user-ul">');

            foreach ($newusersarray as $user)
                    $this->output('<li class="qa-sidebar-user-li-avatar">'.qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'],
                        $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true).'</li>');
                        $this->output('<li class="qa-sidebar-user-li">'.qa_get_one_user_html($user['handle'], false).'<br />'.qa_get_points_title_html(($user['points']), qa_get_points_to_titles()).'

echo "<li class=\"qa-sidebar-user-li-all\"><a class=\"qa-sidebar-user-link-all\" href=\"/users/\">All users</a></li>";
$this->output('</ul>', '');
$this->output('<DIV CLASS="qa-sidepanel-box-unten">');
//    TOPUSERS Function --- END
Thanks, you so helpfull :)
edited by
thanks for your help! It works fine, but If I add the code the top users are shown direclty above the question and answers and not on the sidebar. i can see on your site questions.com.mx that you display the top users in the sidebar without having any position adjustments made in css. can you tell us how to do that? thanks
edited by
I think the problem is that You didnt add the call (first step) inside the sidepanel function. It should look like that for example:

function sidepanel()
            $this->output('<DIV CLASS="qa-sidepanel">');
//    TOPUSERS fucntion call begin
//    TOPUSERS fucntion call end
            $this->output('</DIV>', '');

If it still does not work, please post Your changes to the code here.

Besides, You can take off all the divs and ul´s and li´s in the code i posted 5 days ago, as well the classes, I just copied it directly from one of my sites. You may costumize it as You like.

The most important thing would be the array slice function where You can set another number than 10 to show less users..