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>Cache: Profile 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>Profile: Display Intro Block</title>
<hookname>member_build_blocks_start</hookname>
<phpcode><![CDATA[if (
$vbulletin->options['profileintro']
&& is_member_of( $userinfo, explode( ',', $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($vbulletin, fetch_tag_list());
$userinfo["$introtext"] = $bbcode_parser->parse(addslashes($userinfo["$introtext"]),0, true);
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.
|