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

Reply
 
Thread Tools Display Modes
  #1  
Old 08-26-2013, 03:53 PM
d1jsp d1jsp is offline
 
Join Date: Aug 2013
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Hooking in Custom Variable on FORUMHOME

Hello,

I'm trying to hook in a custom field from the user table, which is used to generate a different image next to usernames in the active users section at the bottom of the forum home page.

I have read and tried to execute the following article to no avail:
https://vborg.vbsupport.ru/showthread.php?t=228078

On the FORUMHOME template is the following code:
PHP Code:
<vb:each from="activeusers" value="loggedin">
<
li>{vb:stylevar dirmark}<class="username" href="{vb:link member, {vb:raw loggedin}}">{vb:raw loggedin.musername}</a>{vb:raw loggedin.invisiblemark}<img src="./images/stars/{vb:raw uinfo.star}" onerror="this.src = 'http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif';" /><!--{vb:raw loggedin.buddymark}-->{vb:raw loggedin.comma}{vb:raw uinfo}</li>
</
vb:each
The code from above that I added in is:
PHP Code:
<img src="./images/stars/{vb:raw uinfo.star}" onerror="this.src = 'http://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif';" /> 
Before doing any of this I did try bbuserinfo, but it will just give the same result for every user (the result being the data that belongs to the viewing user). userinfo also does not work.

Here is the plugin I tried making to make the user information available in the FORUMHOME template:
PHP Code:
$uinfo fetch_userinfo($vbulletin->userinfo['userid']);
$templater vB_Template::create('mytemplate');
    
$templater->register('uinfo'$uinfo);
$templatevalues['uinfo'] = $templater->render();
vB_Template::preRegister('FORUMHOME'$templatevalues); 
I hooked this in at forumdisplay_start, but it seems when I try to print out the uinfo array data it acts as it it doesn't exist.

Does anyone have any suggestions as to what I am doing wrong or if there is an easier way to handle this?

Thanks for looking.

--------------- Added [DATE]1377541481[/DATE] at [TIME]1377541481[/TIME] ---------------

I got it to work. What I did was edit the query found in forum.php to include my custom field in the SELECT statement. Then I was able to use loggedin.star to output the per-user value.
PHP Code:
    $forumusers $db->query_read_slave("
        SELECT
            user.username, (user.options & " 
$vbulletin->bf_misc_useroptions['invisible'] . ") AS invisible, user.usergroupid, user.lastvisit, user.star,
            session.userid, session.inforum, session.lastactivity, session.badlocation,
            IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
            
$hook_query_fields
        FROM " 
TABLE_PREFIX "session AS session
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON(user.userid = session.userid)
        
$hook_query_joins
        WHERE session.lastactivity > 
$datecut
            
$hook_query_where
        " 
iif($vbulletin->options['displayloggedin'] == OR $vbulletin->options['displayloggedin'] == 3"ORDER BY username ASC") . "
    "
); 
--------------- Added [DATE]1377543345[/DATE] at [TIME]1377543345[/TIME] ---------------

Now I'm facing an issue where it works for everyone but for the username of the person viewing the forum.
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 11:45 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03361 seconds
  • Memory Usage 2,228KB
  • 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
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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