Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

How can I show the user's avatar of who made the question in front page

+2 votes
753 views
asked Sep 28, 2014 in Q2A Core by gold.developer

i'm trying to show the persons avatar of who made the question in the front page,I tried to add this

$this->output('<DIV CLASS="qa-q-item-stats">');
$this->post_avatar($q_item, 'qa-q-item');
$this->output('</DIV>');
In  function q_item_main($q_item)  but it's not working... can somebody help me?
Q2A version: 1.6.3

1 Answer

+2 votes
answered Sep 29, 2014 by jatin.soni

in $q_item array you will get user's information. than you can use qa_get_user_avatar_html() function to output the avatar. Something like below







// get require data 
$flags        = $q_item['raw']['flagcount']; 
$email        = $q_item['raw']['email']; 
$handle       = $q_item['raw']['handle']; 
$avatarblobid = $q_item['raw']['avatarblobid']; 
$avatarwidth  = $q_item['raw']['avatarwidth']; 
$avatarheight = $q_item['raw']['avatarheight']; 

// output user avatar 
qa_get_user_avatar_html($flags, $email, $handle, $avatarblobid, $avatarwidth, $avatarheight, 52, false );
commented Sep 29, 2014 by gold.developer
I couldn't be able to make it.. :s
Do I put this inside of this??

function q_item_main($q_item)
        {
            $this->output('<DIV CLASS="qa-q-item-main">');
            $this->q_item_title($q_item);
            $this->q_item_content($q_item);
            $this->output('<DIV CLASS="qa-q-item-meta">');
            $this->a_count($q_item);
            $this->output('</DIV>');
            $this->output('<DIV class="qa-q-item-meta">');
            $this->output(
                '<SPAN CLASS="qa-view-count-data">',
                $this->short_num($q_item['raw']['views']),
                '</SPAN>'
            );
            $this->output('<span class="qa-view-count-pad">views</span>');
            $this->output('</DIV>');
            $this->post_meta($q_item, 'qa-q-item');
            $this->post_tags($q_item, 'qa-q-item');
            $this->q_item_buttons($q_item);
            $this->output('</DIV>');
        }
commented Feb 27, 2015 by delstone
it would work there - yes...
...