Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.3k views
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,

monk333
related to an answer for: Problem with function qa_db_single_select

1 Answer

0 votes
by
 
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.
by
Thank You so much, it works !

Here for others I posted the foreach as it worked for me:

            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()).'
                    ('.number_format($user['points']).')</li>');
 }

With css classes:

.qa-sidebar-user-li {margin-left:60px;padding:0px 5px;background:#fff;margin-bottom:5px;width:130px;height:50px;font-size:12px;}

and

.qa-sidebar-user-li-avatar{float:left;width:50px;height:50px;padding:3px 0px 2px 0px;}
by
great job.

I am using this now :

foreach (array_slice($users,0,5) as $user)
    
             $this->output('<P>'.qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'], $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true).qa_get_one_user_html($user['handle'], false).
     ' ('.number_format($user['points']).')</P>');
by
How to add that in sidebar ? I'm trying at function function sidepanel()
        {....
But i get error.
by
First add this to Your sidepanel function,



//    TOPUSERS fucntion call begin
            $this->topusers();
//    TOPUSERS fucntion call end








After the sidepanel function add this function.

//    TOPUSERS Function --- Begin


function topusers()
        {       
             
       
$users=qa_db_single_select(qa_db_top_users_selectspec(0));

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

$this->output('<DIV CLASS="qa-sidepanel-box-oben">');
$this->output('</DIV>');
   $this->output('<DIV CLASS="sidepanel-box-two">');
   
   $this->output('<h2>');
                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()).'
                    ('.number_format($user['points']).')</li>');
                    
           
           
           
           
            }
                       
                       

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>');
$this->output('<DIV CLASS="qa-sidepanel-box-unten">');
$this->output('</DIV>');
      }
   
//    TOPUSERS Function --- END
by
Thanks, you so helpfull :)
by
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
by
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">');
            $this->sidebar();
            $this->nav('cat');
            $this->output_raw(@$this->content['sidepanel']);
//    TOPUSERS fucntion call begin
            $this->topusers();
//    TOPUSERS fucntion call end
            $this->feed();
            $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..
...