View Full Version : forumhome_lastpostby
DJ-Dez
01-22-2015, 01:05 PM
Heya guys,
How would you display a users avatar in this template? I've tried plugins but the others are not that good and not what I need sadly, so decided to do it myself.
Any ideas what raw code would work to display the avatar of the last posting user?
Thx
nerbert
01-22-2015, 05:05 PM
This is what an avatar image looks like from postbits
<img src="image.php?u=100&dateline=1309261189" alt="JoeBlow's Avatar" title="JoeBlow's Avatar">
I think you could leave out the dateline, I don't even know what's that's for. The alternative would probably to run a query against the avatar table to get avatarpath. I think you would have to do such a query for each forumbit.
To get a username and userid I think you'll need a plugin in "forumbit_display"
$forum['lastposterid'] = $lastpostinfo['lastposterid'];
$forum['lastposter'] = $lastpostinfo['lastposter'];
So an avatar would look like this:
<img src="image.php?u={vb:raw forum.lastposterid}" alt="{vb:raw forum.lastposter}'s Avatar" title="{vb:raw forum.lastposter}'s Avatar">
You may have to experiment around.
I think you could leave out the dateline, I don't even know what's that's for.
The dateline is so that if a user updates his avatar, browsers will request the new one instead of using the cached one, since the url is otherwise the same.
nerbert
01-22-2015, 05:26 PM
That makes sense. But how would you get it without a query against the avatar table? The whole forum.php page seems to be constructed entirely from $vbulletin->forumcache without any query you could put a JOIN into.
I suppose the browser cache would be up to date from the last viewing of showthread
Well yeah, you're right, to do it right you'd need to do a query for each user. Or really you could call fetch_userinfo() with the FETCH_USERINFO_AVATAR parameter, that will do the query for you or get it from the cache if it's there.
What you posted above might be good enough. Maybe it doesn't matter if the avatar doesn't update on that page right away.
OUTL4W
01-22-2015, 06:19 PM
Are you looking for something similar to this?
https://vborg.vbsupport.ru/showthread.php?t=268855
nerbert
01-22-2015, 07:57 PM
But it's for vB3. It probably wouldn't be too hard to figure out the HTML changes if the PHP is still compatible.
ozzy47
01-22-2015, 08:13 PM
Ummm, this one, https://vborg.vbsupport.ru/showthread.php?t=275406
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.