The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
How to get 'userid' in bbcode_quote template?
I am trying to get the userid# of the quoted user so I can display a mini avatar beside the quote in the bbcode_quote template. I can get the username fine, but not the id. {vb:raw postid.userid} seems to get the original poster id # which is no good. I have the below so far. vB 4.2.0.
Code:
<a href="member.php/{vb:raw userid}-{vb:raw username}"> <img src="image.php?u={vb:raw userid}" style="width:27px; height:27px" alt="{vb:raw username}" title="{vb:raw username}" /></a> |
#2
|
|||
|
|||
The user id of the quoted user isn't available - the username of the quoted user comes from the [quote] tag option, but it doesn't include the userid.
You could look it up in the database, but offhand I don't see a good place to do that (and of course it would require a plugin or some other way of modifying the code). |
#3
|
|||
|
|||
Thx. Used member.php?username={vb:raw username} instead for the link part which works fine. Just need to figure out displaying the avatar img now.
|
#4
|
||||
|
||||
I don't know what exactly hook you should use, but trough a vb function you can fetch the userid of the "username" (bbcode option [quote="option"]) and then register the userid in the bbcode_quote template
--------------- Added [DATE]1345915367[/DATE] at [TIME]1345915367[/TIME] --------------- Oh i just remembed that you can just get username from a userid using fetch_userinfo, so this is useless |
#5
|
|||
|
|||
Thanks.
I am completely new to this hook/template thing, and never touched it before. I have the below plugin so far, but it is wrong of course, as it gives errors in the weblogs (PHP Fatal error: Only variables can be passed by reference...). What am I missing? All I need really is the User ID returned to bbcode_quote so I can complete a URL so it displays the avatar (ie. ...src="image.php?u={vb:raw quote_userid}...) Code:
require_once('./includes/functions_user.php'); $userid = fetch_userinfo(1); $quote_userid = $userid; $templater = vB_Template::create('bbcode_quote'); $templater->register('quote_userid', $quote_userid); $templater->render(); |
#6
|
||||
|
||||
Quote:
SELECT+userid+from+user+WHERE+username+=+$option Where option is what the user put after = (quote="option"), but i don't how you can get it and in what hook.. + |
#7
|
|||
|
|||
Tried something else. First, I changed to file based avatars instead of dbase based. I then edited class_bbcode.php with code below in the 'handle_bbcode_quote' function to get the userid (which worked fine).
Code:
$result = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "post"); while ($row = $vbulletin->db->fetch_array($result)) { if ($row['postid'] == $postid) { $userid = $row['userid']; } } I also added the below code to display the avatar (underneath the above code). It 'works'. However, the avatar is not updated if the user changes their avatar. ie. avatar1_9.gif is the new avatar, but is still trying to display avatar1_8.gif. Code:
require_once(DIR . '/includes/functions_user.php'); $quote_avatar_url = fetch_avatar_url($userid); if ($quote_avatar_url) { $quote_avatar_url = $quote_avatar_url[0]; } else { $quote_avatar_url = "images/misc/unknown.gif"; } |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|