Log in

View Full Version : fetch_avatar_url()


Jacob B
09-25-2008, 04:04 AM
I'm looking for a way to fetch a users avatar to display inside a modification, a ticket support system. I've done a search and been through about 60+ pages of avatar modifications and can't find the actual code for it. I'm not exactly sure where I would need to insert the code into the PHP file, plus using the avatar conditional (<if condition="$show['avatar']">) doesn't seem to work on the modification.

Basically, this is how I've got it setup. This is the "ticket_display" template:

<if condition="$issue[status]==0">

<img src="$stylevar[imgdir_button]/threadclosed.gif" border="0" alt"" />

</if>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top">

<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" style="border-bottom-width:0px">
<tr align="left">
<th class="tcat" width="100%">
$issue[title]
</th>
<if condition="$show['member']">
<th class="vbmenu_control" id="issuetools" nowrap="nowrap">
<a href="$vbptions[bburl]/issue.php?$session[sessionurl]do=issuetools">Issue Tools</a>
<script type="text/javascript">vbmenu_register("issuetools");</script>
</th>
</if>
</tr>
</table>

<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%">
<tr>
<td class="thead normal">

<if condition="$show['can_delete_issues'] OR $show['can_delete_any_issues']">
<div style="float:right">
[<a href="$vboptions[bburl]/issue.php?$session[sessionurl]do=delete&amp;id=$_REQUEST[id]">Delete</a>]
</div>
</if>

<img src="$stylevar[imgdir_statusicon]/post_new.gif" alt="#$_REQUEST[id]" class="inlineimg" />
$ticket[datelogged]
</td>
</tr>
<tr valign="top">
<td class="alt2">
<table cellpadding="0" cellspacing="6" border="0" width="100%">
<tr>
<td class="alt2">
<if condition="$show['avatar']">
<a href="$vboptions[bburl]/member.php?$session[sessionurl]u=$issue[ownerid]"><img src="$vboptions[bburl]/image.php?u=$issue[ownerid]" alt="" border="0" />
</if>






</td>
<td nowrap="nowrap" width="100%">

<div id="notemenu_68661">

<a class="bigusername" href="$vboptions[bburl]/member.php?$session[sessionurl]u=$issue[ownerid]">$issue[ownerusername]</a>






</div>
<div class="smallfont">Posted <span class="time">$issue[datelogged]</span></div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="alt1" valign="top">

<div style="font-size:12pt">$issue[title]</div>
<div><strong></strong></div>
<hr style="border:0px; height:1px; color:#D1D1E1; background-color:#D1D1E1" />
<div>$issue[message]</div>

<div class="smallfont" align="right" style="margin-top:12px">
<div style="float:left" align="left">



</div>
<if condition="$show['can_edit_issues'] OR $show['can_edit_any_issues']">
<a href="$vboptions[bburl]/issue.php?$session[sessionurl]do=edit&amp;id=$_REQUEST[id]"><img src="$stylevar[imgdir_button]/edit.gif" alt="Edit" border="0" /></a>
</if>

</div>

</td>
</tr>


</table>



</td>
</tr>
</table>



<br />
<a name="comments"></a>
<div style="font-size:12pt">Comments</div>
<div style="height:3px">&nbsp;</div>

For some reason using the 'avatar' conditional is hindering the ability to display the user's avatar. It simply doesn't show. I've never written the PHP code to fetch an avatar. I've tried this code only it results in a database error:

require_once('./includes/init.php');
require_once('./includes/functions_user.php');
$issue['owner_avatar']=fetch_avatar_url($issue['ownerid']);
if ($issue['owner_avatar']=='') ($bbuserinfo['owner_avatar']='images/misc/noavatar.gif');
$issue['owner_avatar']="<img src='$vboptions[bburl]/{$issue['owner_avatar']}' border='0'>";
$issue['owner_avatar']="<a href='$vboptions[bburl]/profile.php?{$session['sessionurl']}&do=editavatar'>{$issue['owner_avatar']}</a>";
$issue_avatar=$issue['owner_avatar'];

How do I fetch the avatar? Sorry to ask guys, but this is driving me insane. I can't use $bbuserinfo because that will only display the avatar of the user browsing the actual modification.

Dismounted
09-25-2008, 04:36 AM
You know that fetch_avatar_url() returns an array, right? ;)

Jacob B
09-25-2008, 04:54 AM
I have no idea, that's why I'm asking. lol

Dismounted
09-25-2008, 05:45 AM
Well, if you're using a function you have no idea about, why don't you have a look at it first?

Jacob B
09-25-2008, 06:22 AM
That's the thing, I'm not using it. I'm asking you kindly if you could possibly point me in the right direction as to where I can find how to use it and how to impliment it into my PHP file. I've been through API and found nothing relevant in regard to what I'm looking for, and what I require.

I'm not a vBulletin expert, so I do require help from time to time. I'm a grunt, not a development engineer. I'm looking for the code that I would be required to write into my product to fetch a user's avatar to display inside the modification for each issue and reply posted. Nothing more, nothing less. So for example, if a user posted a support issue, I would write the following to display his/her relevant avatar if applicable:


<if condition="$show['avatar']">
<a href="$vboptions[bburl]/member.php?$session[sessionurl]u=$issue[ownerid]"><img src="$vboptions[bburl]/image.php?u=$issue[ownerid]" alt="Avatar" title="$issue[ownerusername]'s Avatar" border="0" /></a>
</if>


As I explained, the conditional <if condition="$show['avatar']"> doesn't appear to work in this modification. I find it strange because both 'member' and 'guest' conditionals function correctly inside the modification, so I don't quite understand why the 'avatar' conditional does not work. My first thought was 'Perhaps I need to write a table or something to fetch the user's avatar?' as if I cannot get conditionals to work, then I am unsure of other options.

So if anybody has any information as to why the 'avatar' conditional does not work, and how I can get it to function correctly, it would be greatly appreciated.

Dismounted
09-25-2008, 07:28 AM
$show['avatar'] doesn't work because it's not defined ;). And yes, you do have to fetch the avatar. The API doesn't really do much apart from listing arguments and what file it's in, so go into the file itself and look what happens.