View Single Post
  #55  
Old 07-12-2012, 01:02 AM
Cognitio Cognitio is offline
 
Join Date: Jun 2012
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Attached Images
File Type: png Screenshot1.png (55.0 KB, 0 views)
File Type: png Screenshot2.png (43.7 KB, 0 views)
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01233 seconds
  • Memory Usage 1,978KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)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
  • (2)postbit_attachment
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete