Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
765 views
in Q2A Core by
edited by
Something like that on the front page where the questions are listed: asked 21 hours ago in Auto by Cromatic (USERID) from LOCATION (180 points)

Thanks alot!

1 Answer

+2 votes
by
Interesting question!

Look at qa_who_to_html(...) in qa-app-format.php. Adding the user ID is fairly easy. Immediately after these two lines:

if ($microformats)
    $whohtml='<SPAN CLASS="vcard author">'.$whohtml.'</SPAN>';

Add:

$whohtml.=' ('.qa_html($postuserid).')';

Adding the location is a lot harder, since Q2A doesn't currently map IP addresses to locations.
by
Thanks alot for your answer! Unfortunatly it's not constructive for what i am trying to do.

In qa-theme-base.php after:

        function q_item_main($question)
        {
            $this->output('<DIV CLASS="qa-q-item-main">');


I added this:

$this->output('<img align="left" src="USERID.jpg" width="80" height="60" border="0"');

Instead of USERID I want to add the "userid" from database so will result for instance 1.jpg, 5.jpg, 64.jpg etcetera.

Also, I saw a problem with your earlier solution that for the logged in user the USERID was not showing up.

Thank you very much for your help, I really appreciate if you could give me a hand with this.
by
The problem is that the userid is not available to q_item_main(...), so you can't access it there.

I don't see a reason why you can't use the method I suggested with images too. You can put any HTML code that you want instead of the ( ) brackets above. So why not:

$whohtml.=' <img align="left" src="http://URL/OF/USER/IMAGE/DIRECTORY/'.qa_html($postuserid).'.jpg" width="80" height="60" border="0"';

Note that you'll need an absolute URL like my example above for this to work on every page of your site.

If you want it to apply to the logged in user too, just change this in qa_who_to_html(...):

if ($isbyuser)

... to ...

if (false)
by
Perfect! Thank you so much. One more thing though: How can we modify so the picture won't show for the user that edited and when the posted question is anonymous, there to apear no pic also?

Once again,
million thanks!
by
Make a copy of the function qa_who_to_html(...) with a different name, which uses the original code, and call that one instead for the line the starts: $fields['who_2']=...

If you put the code in the conditional brackets like in my original answer, it will not show an image for anonymous users.
by
Thank you very much Gideon. All worked perfectly! I will probably encounter other problems too while trying to customize the script and hope I will not become a pain in the @ss with my questions.

Thanks alot!
...