vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   Using your User Profile Fields in your postbit templates (w/ all plugin method) (https://vborg.vbsupport.ru/showthread.php?t=250418)

MarkFL 07-24-2015 03:03 PM

Okay, try using the plugin code:

PHP Code:

if ($post['field17'])
{
    switch (
$post['field17']) {
        case 
1:
            
$hmtitle '<img src="http://i.imgur.com/TdZqV1q.gif?1" title="Ravenclaw" alt="Ravenclaw" />';
            break;
        case 
2:
            
$hmtitle 'Montresor';
            break;
        case 
4:
            
$hmtitle 'Astor';
            break;
        case 
8:
            
$hmtitle 'Lore';
            break;
        case 
16:
            
$hmtitle 'Bluteisen-Ravenclaw';
            break;
        case 
32:
            
$hmtitle 'Pendrake';
            break;
        default:
            
$hmtitle 'Default';
    }
    
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt>House Membership</dt> <dd>' $hmtitle '</dd>';


What do you get now?

ProfC 07-24-2015 03:13 PM

"House Membership: Default", I have "Ravenclaw" selected in my profile. I edited my profile to leave it blank, and the field disappeared but upon changing it to Ravenclaw again, it went to "Default" on the postbit.

MarkFL 07-24-2015 03:18 PM

Okay, it sounds to me that the value being stored in the variable $post['field17'] isn't what you are expecting.

ProfC 07-24-2015 03:43 PM

It seems it.

I'm not sure what I may have done wrong. This is a screenshot of the profile field from the ACP.

MarkFL 07-24-2015 04:25 PM

Okay, try this as your plugin code:

PHP Code:

if ($post['field17'])
{
    
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt>House Membership</dt> <dd>' $post['field17'] . '</dd>';



ProfC 07-24-2015 05:45 PM

That works perfectly, thank you. :) It seems I was in fact using the wrong method. Now the question would be on how to get it to display a different image based on the option selected on your profile.

MarkFL 07-24-2015 05:55 PM

Do your images have the options for field17 embedded in their URL? If so you could easily build the HTML using string concatenation. Suppose your images are stored in the folder "images/housemembership" and their filenames are composed of the options and the extension ".png". Then you would use the plugin code:

PHP Code:

if ($post['field17'])
{
    
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt>House Membership</dt> <dd><img src="images/housemembership/' $post['field17'] . '.png" /></dd>';



ProfC 07-24-2015 06:01 PM

They don't, but I'll work on that later tonight and see what I can whip up. Thank you ^^

MarkFL 07-24-2015 06:04 PM

Quote:

Originally Posted by ProfC (Post 2551262)
They don't, but I'll work on that later tonight and see what I can whip up. Thank you ^^

Rather than rename the folder and files, it would be easier to construct a switch statement to build the element. Just let me know the folder name and which image filename goes with which option, and I will write the plugin code. ;)

ProfC 07-24-2015 06:43 PM

Quote:

Originally Posted by MarkFL (Post 2551263)
Rather than rename the folder and files, it would be easier to construct a switch statement to build the element. Just let me know the folder name and which image filename goes with which option, and I will write the plugin code. ;)

Thank you :)

I'll drop you a message in a few moments with everything.


All times are GMT. The time now is 11:54 AM.

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.01102 seconds
  • Memory Usage 1,749KB
  • 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
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete