TinyPortal

General => Chit chat => Topic started by: Porky on September 27, 2006, 12:20:12 AM

Title: Need some Coding Help
Post by: Porky on September 27, 2006, 12:20:12 AM
echo '</font></font></a><br><font size="1"> ' . $row2['personalText'] . '</font></a></td><td class="windowbg2">' . $row2['usertitle'] . '</td>';
        echo '<td class="windowbg">' . timeformat($row2['lastLogin']) . '</td>';
        echo '<td class="windowbg2" align="center">';
        echo '<i>' . $row2['location'] . '</i>';
        echo '</td><td class="windowbg">';


How due I change the usertitle code so that it will display usertitles instead it wi;; show members avatar?
Title: Re: Need some Coding Help
Post by: JPDeni on September 27, 2006, 12:40:22 AM
I'm not sure how the directories work really, but as a start you can try
echo '</font></font></a><br><font size="1"> ' . $row2['personalText'] . '</font></a></td><td class="windowbg2"><img src="' . $row2['avatar'] . '"></td>';

I think, based on the context that this is what you want, but it's a little hard to tell for sure.
Title: Re: Need some Coding Help
Post by: Porky on September 27, 2006, 12:43:52 AM
Yeah I tried that all that shows up is the avatar name not the picture...I am trying to change a php article to show the persons avatar in that table instead of there personal text.
Title: Re: Need some Coding Help
Post by: JPDeni on September 27, 2006, 12:46:58 AM
So you tried

<img scr="' . $row2['avatar'] . '">
and you got the avatar name? That's pretty strange. Could I see it in action?
Title: Re: Need some Coding Help
Post by: Porky on September 27, 2006, 12:50:30 AM
http://www.devilsrejectsdod.com/smf/index.php?page=11 this is the link give me a csec and I will put in avatar
Title: Re: Need some Coding Help
Post by: Porky on September 27, 2006, 12:58:47 AM
I put it in Like you had it and it dispalys nothing...
Title: Re: Need some Coding Help
Post by: JPDeni on September 27, 2006, 01:09:56 AM
Okay. It's not just printing the avatar name, though. It's indicating that an image should go there. Now it's just a matter of telling it where the avatar directory is.

At the beginning of your php article, add

global $modsettings;

Change the img tag to

<img scr="' . $modSettings['avatar_url'] . '/' . $row2['avatar'] . '">

That will probably only work if the images are on your server. I haven't looked into avatars enough to have much more information, though.
Title: Re: Need some Coding Help
Post by: Porky on September 27, 2006, 01:19:07 AM
nope That ain't it
Title: Re: Need some Coding Help
Post by: Porky on September 27, 2006, 01:20:36 AM
This is the full orginal code  http://www.tinyportal.net/smf/index.php?topic=5423.msg63479#msg63479
Title: Re: Need some Coding Help
Post by: JPDeni on September 27, 2006, 01:23:49 AM
Well, it seems I have a typo that neither one of us caught. Let's try it again.

<img src="' . $modSettings['avatar_url'] . '/' . $row2['avatar'] . '">

Also, I need to know for sure what your current code is so that I can compare it to the source code on your page so I can see what's going on.
Title: Re: Need some Coding Help
Post by: Porky on September 27, 2006, 01:25:44 AM
Thats it thanks for all your help +2 to Karma for you
Title: Re: Need some Coding Help
Post by: Porky on September 27, 2006, 01:27:35 AM
Here is another question is there a way to lock the tables so they are all the same so they don't ofset from the one above it...look http://www.devilsrejectsdod.com/smf/index.php?page=11
Title: Re: Need some Coding Help
Post by: jacortina on September 27, 2006, 05:29:36 AM
Quote from: JPDeni on September 27, 2006, 01:23:49 AM
<img src="' . $modSettings['avatar_url'] . '/' . $row2['avatar'] . '">

I don't believe this will work for offsite (remotely stored) avatars, which would require a conditional: if the $row['avatar'] started with "http", just use the value (or, rather, only prepend the "$modSettings['avatar_url'] . '/' ." when it doesn't start that way).
Title: Re: Need some Coding Help
Post by: JPDeni on September 27, 2006, 02:57:18 PM
You're right jacortina. More would have to be done. I just gave him the information that I could find pretty easily, since this is the first time I've looked at avatars.

humanporkrind, in order to get all the tables lined up, you would need to add width tags to each of the table cells in the first row of each table.
Title: Re: Need some Coding Help
Post by: Porky on September 29, 2006, 12:08:28 AM
So add it with in this
echo '<table border="0" cellspacing="1" cellpadding="5" align="center" class="bordercolor">
Title: Re: Need some Coding Help
Post by: JPDeni on October 03, 2006, 09:20:36 PM
This is better code for the avatar.

Make sure you add

global $context;

to the top of your article. (Or, if you've already got a "global" line, add $context to it.) and then use the following code for your avatar:

if (!empty($context['user']['avatar']) && isset($context['TPortal']['userbox']['avatar']))
echo $context['user']['avatar']['image'];
[/code[