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)

Lynne 06-25-2015 05:26 PM

Since you didn't use the code tags, it looked like your code was not all on one-line, which it needs to be if you don't use the parenthesis.

You don't use that code for a radio button though. That code is for Multiple-Selection Menu and Multiple-Selection Checkbox profile fields. You need to use the code for For Single-Line Text Box, Multiple-Line Text Box, Single-Selection Radio Buttons, and Single-Selection Menu profile fields.

ProfC 07-09-2015 08:44 PM

Hi Lynne,

Is it possible to display a different image on the postbit depending on the option chosen on a single-selection menu?

Example: "What is your favourite colour?"
Red
Blue
Green
Orange

I've used method one but am suspecting that method two may actually be more suitable for this task.

Thank you in advance,

ProfC.

Lynne 07-10-2015 03:01 PM

You could use either template edits or a plugin to do what you want. In the examples I show, just replace 'Your 1rst option' with '<img src="image.png" alt="Red Image" height="xx" width="yy">'

ProfC 07-10-2015 03:25 PM

Quote:

Originally Posted by Lynne (Post 2549860)
You could use either template edits or a plugin to do what you want. In the examples I show, just replace 'Your 1rst option' with '<img src="image.png" alt="Red Image" height="xx" width="yy">'

Thank you! I'll take a look and see what I get. :)

friendlymela 07-21-2015 03:28 PM

Good advices thanks for share this

ProfC 07-24-2015 12:05 PM

I'm having a bit of trouble somewhere with this. I decided to go the plugin method for multiple selection fields, as it seemed to offer the means to set different things to display based on the option selected. Unfortunately, I haven't been able to get any further than it displaying "house memberships" (the field name) on the postbit.

I'm not sure whether I've even used the right method or not but the "single selection menu" method didn't appear to have the options to display a different result based on what was selected in the profile menu.

Would it be possible for someone to tell me where I've gone wrong? (I get the sensation I'll be asking this a lot -sigh-) Thank you in advance :)

Plugin code:
Code:

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


MarkFL 07-24-2015 12:22 PM

You want to use "==" instead of "&" in your conditionals. However, might I suggest using a switch statement instead?

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;
    }
    
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt>House Membership</dt> <dd>' $hmtitle '</dd>';



ProfC 07-24-2015 01:48 PM

Thank you; although it appears I'm getting the same result using your version as I am with the one I added following the article.

MarkFL 07-24-2015 02:46 PM

What hook location are you using?

ProfC 07-24-2015 02:52 PM

"postbit_display_complete" as mentioned in the article.


All times are GMT. The time now is 09:21 AM.

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.03436 seconds
  • Memory Usage 1,748KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)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