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-08-2012 03:34 PM

Quote:

Originally Posted by Tri@de (Post 2337748)
There's a way to use profile fields also in other pages like cms articles?

I'm sure there is, but this article is not about that, it is about using them in the postbit template.

Cognitio 07-09-2012 09:08 PM

I've set this up using the advanced method but when it displays I only get the binary number and not the array of choices selected... what am I doing wrong?

Lynne 07-09-2012 11:47 PM

Quote:

Originally Posted by Cognitio (Post 2346489)
I've set this up using the advanced method but when it displays I only get the binary number and not the array of choices selected... what am I doing wrong?

I don't know. How about a screen shot of your admincp profile field set up and the exact code/hook for your plugin.

Cognitio 07-12-2012 01:02 AM

1 Attachment(s)
I actually altered this into another mod - Profile Intro. The mod adds a memberprofile header that displays custom profile fields defined from the usercp. The mod itself displays input and textarea fields fine, but when it comes to multi_select fields they only display the binary code. I searched through and found this article and attempted to alter it into the Profile Intro mod, the basic function that would require a template modification every time I change a custom field works fine, but I rather have the more advanced option work for ease of use.

Here's the template code I used:
PHP Code:

<template name="memberinfo_block_intro" templatetype="template" date="1321436160" username="phpdesk" version="1.0.3"><![CDATA[    <div class="collapse intro_block">
        <
vb:if condition="$userinfo[$introtitle]"><h2><span><a href="http://{vb:raw userinfo.$introlink}">{vb:raw userinfo.$introtitle}</a> | ({vb:raw userinfo.$introloc})</span></h2></vb:if>
        <
div class="text<vb:if condition="$userinfo[$introtitle]"> noborder</vb:if>"><p>Skills: {vb:raw userinfo.$introtypedef2} | 
            <
vb:if condition="$userinfo[$introtype] & 1"> {vb:raw userinfo.$introtype}-1,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 2"> {vb:raw userinfo.$introtype}-2,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 4"> {vb:raw userinfo.$introtype}-3,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 8"> {vb:raw userinfo.$introtype}-4,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 16"> {vb:raw userinfo.$introtype}-5,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 32"> {vb:raw userinfo.$introtype}-6,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 64"> {vb:raw userinfo.$introtype}-7,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 128"> {vb:raw userinfo.$introtype}-8,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 256"> {vb:raw userinfo.$introtype}-9,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 512"> {vb:raw userinfo.$introtype}-10,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 1024"> {vb:raw userinfo.$introtype}-11,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 2048"> {vb:raw userinfo.$introtype}-12,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 4096"> {vb:raw userinfo.$introtype}-13,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 8192"> {vb:raw userinfo.$introtype}-14,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 16384"> {vb:raw userinfo.$introtype}-15,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 32768"> {vb:raw userinfo.$introtype}-16,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 65536"> {vb:raw userinfo.$introtype}-17,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 131072"> {vb:raw userinfo.$introtype}-18,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 262144"> {vb:raw userinfo.$introtype}-19,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 524288"> {vb:raw userinfo.$introtype}-20,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 1048576"> {vb:raw userinfo.$introtype}-21,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 2097152"> {vb:raw userinfo.$introtype}-22,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 4194304"> {vb:raw userinfo.$introtype}-23,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 8388608"> {vb:raw userinfo.$introtype}-24,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 16777216"> {vb:raw userinfo.$introtype}-25,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 33554432"> {vb:raw userinfo.$introtype}-26,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 67108864"> {vb:raw userinfo.$introtype}-27,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 134217728"> {vb:raw userinfo.$introtype}-28,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 268435456"> {vb:raw userinfo.$introtype}-29,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 536870912"> {vb:raw userinfo.$introtype}-30,</vb:if>
            <
vb:if condition="$userinfo[$introtype] & 1073741824"> {vb:raw userinfo.$introtype}-31</vb:if>
        </
p></div>
        <
div class="text<vb:if condition="$userinfo[$introtitle]"> noborder</vb:if>"><p>{vb:raw userinfo.$introtext}</p></div>
    </
div>]]></template

and here's the plugins code I used (profileintro_typefield is defined as the profilefieldid already):
PHP Code:

<plugin active="1" executionorder="5">
            <
title>Add User Profile Fields to Postbit Templates 1</title>
            <
hookname>init_startup</hookname>
            <
phpcode><![CDATA[if (THIS_SCRIPT == 'member'$GLOBALS['phrasegroups'][] = 'cprofilefield';]]></phpcode>
        </
plugin>
        <
plugin active="1" executionorder="5">
            <
title>Add User Profile Fields to Postbit Templates 2</title>
            <
hookname>member_build_blocks_start</hookname>
            <
phpcode><![CDATA[if (THIS_SCRIPT == 'member')
{
    
$typefielddef $vbulletin->options['profileintro_typefield'];
    
$profilefieldx =  $vbulletin->db->query_first("SELECT profilefieldid, type, data  FROM " TABLE_PREFIX "profilefield` WHERE profilefieldid = $typefielddef");
    
$userinfo['profilefieldx'] = $profilefieldx;
}]]></
phpcode>
        </
plugin>
        <
plugin active="1" executionorder="5">
            <
title>CacheProfile Intro Templates</title>
            <
hookname>cache_templates</hookname>
            <
phpcode><![CDATA[if (THIS_SCRIPT == 'member')
{
    
$cache[] = 'memberinfo_block_intro';
}


if(
THIS_SCRIPT=='css')
{
    
$cache[] = 'profile-intro.css';
}]]></
phpcode>
        </
plugin>
        <
plugin active="1" executionorder="5">
            <
title>ProfileDisplay Intro Block</title>
            <
hookname>member_build_blocks_start</hookname>
            <
phpcode><![CDATA[if (
    
$vbulletin->options['profileintro']
    && 
is_member_of$userinfoexplode','$vbulletin->options['profileintro_groups'] ) )
)
{
    
$introtitle 'field' $vbulletin->options['profileintro_titlefield'];
    
$introtype 'field' $vbulletin->options['profileintro_typefield'];
    
$introtext 'field' $vbulletin->options['profileintro_textfield'];
    
$introlink 'field' $vbulletin->options['profileintro_linkfield'];
    
$introloc 'field' $vbulletin->options['profileintro_locfield'];
    
    if ( 
$introtype )
    {
        
$fieldarrayx $userinfo['profilefieldx'];
        
fetch_profilefield_display($fieldarrayx$introtype);
        
$introtypedef2 $fieldarrayx["value"]; 
    }

    if ( 
$userinfo["$introtext"] )
    {
        
$userinfo["$introtitle"] = addslashes($userinfo["$introtitle"]);

        
// parse bbcode
        
require_once(DIR '/includes/class_bbcode.php');
        
$bbcode_parser = new vB_BbCodeParser($vbulletinfetch_tag_list());
        
$userinfo["$introtext"] = $bbcode_parser->parse(addslashes($userinfo["$introtext"]),0true);

        if (
$vbulletin->versionnumber '4.0.8')
        {
            
$template '<div class="member_tabs">';
        }
        else
        {
            
$template '<div class="tabbackground" id="profile_tabs">';
        }

        
$templater vB_Template::create('memberinfo_block_intro');
        
$templater->register('introtitle'$introtitle);
        
$templater->register('introtype'$introtype);
        
$templater->register('introtext'$introtext);
        
$templater->register('introlink'$introlink);
        
$templater->register('introloc'$introloc);
        
$templater->register('userinfo'$userinfo);
        
$templater->register('introtypedef2'$introtypedef2);

        
$vbulletin->templatecache['MEMBERINFO'] = str_replace(
            
$template$template $templater->render(),
            
$vbulletin->templatecache['MEMBERINFO']
        );
    }
    
    
}]]></
phpcode>
        </
plugin

Attached are two screen shots, the first is of the display results of the Profile Intro mod within the member.php, and the second screen shot is of the admincp of the customfields as requested. As seen in the first screen shot, the array is correctly shown in the 'About Me' section (which I couldn't find the coding on what to copy to project in the mod), but in the Profile Intro mod it's the binary code and the text I supplied within the coding to define each multi_select option.

Cognitio 08-02-2012 02:59 PM

I'm just going to assume I'm being ignored...

TheSupportForum 09-09-2012 08:49 AM

hi need help converting this into a plugin for postbit_legacy for the following template hook

$template_hook['postbit_userinfo_right_after_posts']


HTML Code:

<vb:if condition="$post['field5']">
  <dt>eRepublik</dt> <dd><a href="http://www.erepublik.com/en/citizen/profile/{vb:raw post.field5}"><img src="http://www.legijastranaca.com/images/erep/citizen.png" alt="Citizen link" width="25" height="24" border="0"></a><a href="http://www.erepublik.com/en/main/messages-compose/{vb:raw post.field5}"><img src="http://www.legijastranaca.com/images/erep/message.png" alt="Message Citizen on eRepublik" width="24" height="24" border="0"></a><a href="http://www.erepublik.com/en/economy/donate-items/{vb:raw post.field5}"><img src="http://www.legijastranaca.com/images/erep/donate.png" alt="Donate Items" width="24" height="24" border="0"></a></vb:if>


Lynne 09-09-2012 02:55 PM

Did you try converting it using this as an example?
PHP Code:

if ($post['fieldx'])
{
    
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt>My FieldX</dt> <dd>' .$post[fieldx]. '</dd>';



omega79 09-25-2012 09:45 AM

is there any plugin to download to just simply change it without adding code to some templates?

Lynne 09-25-2012 02:37 PM

Quote:

Originally Posted by omega79 (Post 2368372)
is there any plugin to download to just simply change it without adding code to some templates?

Under the More Advanced section of my post, I posted the plugin codes. I cannot write a plugin for you to download since you need to enter the fieldid.

TheSupportForum 09-25-2012 06:57 PM

Quote:

Originally Posted by Lynne (Post 2364015)
Did you try converting it using this as an example?
PHP Code:

if ($post['fieldx'])
{
    
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt>My FieldX</dt> <dd>' .$post[fieldx]. '</dd>';



Lynee i always have issues inserting hyperlinks

i want to do something like this


PHP Code:

if ($post['fieldx'])
{
    
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt>My FieldX</dt> <dd>' http://www.domain.com/ .$post[fieldx]. '>link</a></dd>';




All times are GMT. The time now is 12:09 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.03554 seconds
  • Memory Usage 1,891KB
  • 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_html_printable
  • (5)bbcode_php_printable
  • (4)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