Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-25-2012, 12:44 PM
oldz442 oldz442 is offline
 
Join Date: May 2012
Location: Canada
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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>
Reply With Quote
  #2  
Old 08-25-2012, 01:06 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #3  
Old 08-25-2012, 03:37 PM
oldz442 oldz442 is offline
 
Join Date: May 2012
Location: Canada
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 08-25-2012, 04:06 PM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 08-26-2012, 01:34 AM
oldz442 oldz442 is offline
 
Join Date: May 2012
Location: Canada
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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();
Reply With Quote
  #6  
Old 08-26-2012, 10:06 AM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by oldz442 View Post
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();
Why are you using 1 as paramater? As i said you don't need fetch_userinfo function as it requires the userid (that you don't know) all you need to do is a query something like

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.. +
Reply With Quote
  #7  
Old 08-30-2012, 07:57 AM
oldz442 oldz442 is offline
 
Join Date: May 2012
Location: Canada
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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";
}
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:57 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03857 seconds
  • Memory Usage 2,222KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete