vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Hooking in Custom Variable on FORUMHOME (https://vborg.vbsupport.ru/showthread.php?t=301636)

d1jsp 08-26-2013 03:53 PM

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.


All times are GMT. The time now is 06:51 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.01083 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete