The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Avatar display issue in template
Hello,
Considering I don't like to bump pretty old threads, thought I'd make a new one. I've been focusing on getting the avatar to display properly in showgroups.php; it should also update as staff members change the avatar. So far I've gotten pretty far, although I'm a bit stuck now. From my understanding, I can use the fetch_avatar_url() function as to fetch the current avatar url. As such, I did the following: PHP Code:
PHP Code:
Help would be greatly appreciated! |
#2
|
|||
|
|||
It's always showing yours because you're using the userid and username from $vbulletin->userinfo, which is the logged in user.
ETA: if your code is in that main loop in showgroups.php, it looks like you'd want to use $user['userid'] and $user['username'] instead. |
#3
|
|||
|
|||
Thanks for the quick response. Much appreciated.
I've searched through the showgroups.php file and I could not seem to figure out which variable to use then. Considering $vbulletin->userinfo[] is for the logged in user, which should I use instead? If I use $user[userid], $user['userid'], $userinfo['userid'], or $userinfo[userid], I get either a DB error as it would say 'WHERE user.id=', with no id at all. Or otherwise, I would simply have no ID at the end of the URL of the avatar/user. |
#4
|
|||
|
|||
Using $user[userid] and $user[username] should work, but only if your code is inside the loop that starts with:
PHP Code:
|
#5
|
|||
|
|||
Alright, I've changed the hook to showgroups_user and also have added the if condition into the foreach loop. The avatars changed according to the user now, along with the username and ID. Thanks.
However, if I change it in my UserCP, showgroups.php shows the old avatar still. Why is this happening, considering as far as I know, the forum uses the filesystem and/or DB? EDIT: Also, the usernames seem to have vanished; only avatar is visible now. Tried reverting template, but that didn't work. |
#6
|
|||
|
|||
Quote:
Code:
[S]<img src="$aviurl" ...[/S] (wrong - see below) I don't know about the user names. |
#7
|
|||
|
|||
Well this is getting into the right direction!
I've replaced the img tag's src with: Code:
<img src="'.(implode($avauri)).'" /> Code:
<img src="1image.php?u=1&dateline=1295535226 width=" 120"="" height="26" "="" border="0" alt="" /> I guess I'm either doing this wrong, or the Array isn't supposed to be there (thus, $avauri)? Also, much appreciated for taking your time to response. |
#8
|
|||
|
|||
Yeah, sorry - I should have looked at fetch_avatar_url before assuming I knew what it returns. It does return an array, and it seems like it either just has one array element with the url, or else it has a "hascustom" element set to 1, with a number of other fields. I looked for other places that call fetch_avatar_url, but I'm still not sure how it's all supposed to be used. Here's one from user.php (in admincp, I think):
PHP Code:
It could be that fetch_avatar_url is only used in a few special places because it does a query to get the answer, so if you put it on a page with a lot of avatars it's going to add a lot of queries (which maybe doesn't matter to you, but just so you know..). |
#9
|
|||
|
|||
Hello,
My apologies for the slow reply. Been quite busy these few days. Indeed, the return value of fetch_avatar_url() is set to 1 on both avatar URIs, so I'm assuming that the 1 is the result of 'hascustom', moreso than it being an actual array element identifier. Oddly enough, using implode() for the variable $avauri (which is fetch_avatar_url()), would result in it actually giving its own width and height parameters, but moreso in a buggy way: Code:
<img src="1image.php?u=2&dateline=1295528513 width=" 120"="" height="26" "="" I'm really eager to get this working, for it'd be a great addition to my fourth 'mod'. Also, I'd like to thank you once more for taking your time to assist me in this matter. |
#10
|
|||
|
|||
I suppose the values were returned that way because sometimes just the path is needed and sometimes the width and height are also needed.
Yes, I don't think it was meant to be imploded because of the hascustom thing in there. I guess you could either use PHP Code:
or if you wanted to use implode do something like PHP Code:
first. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|