View Full Version : Profile Field Value
I have run several searches on .org and even tried seeing how some had gotten things to show via their mods and I am still drawing a blank.
What I am Trying To Do
All I am trying to do is display the value of a custom profile field within a new tab on the profile. I am looking to render the inputed value as a link so it would appear like this within the template:
<a href="{raw $userinfo['field281']">Title here</a>
The field ID is 281 but no matter how I write it, and I have tried several variations, I can't get it to show the value. I would appreciate any help with this.
Did you try {vb:raw userinfo.field281} ?
I may have, it didn't work when I just tried it. I also wanted to wrap it in an if conditional like so:
<vb:if condition="$userinfo['field281']">
$userinfo['field281']
</vb:if>
How did you create your new tab?
I followed this:
https://vborg.vbsupport.ru/showthread.php?t=265971
Oh, OK, I think you need to register $userinfo for use in your custom template, like this:
$templater->register('userinfo', $userinfo);
then I think what you have in post #3 should work. The condition you have in post #3 should work, but you need {vb:raw userinfo.field281} inside the if.
I tried this as well. I can get it to work with
<vb:if condition="$bbuserinfo['field281']">
{vb:raw bbuserinfo.field281}
</vb:if>
That obviously shows my info though. It just doesn't want to show their info when I am viewing it. lol Thanks for your help. I will keep digging. lol
Right, as you figured out I was wrong about post#3, the condition is correct but the tag inside needs to be a vb:raw tag.
So you added the register call where you're rendering your custom template and it still didn't work? If you want to post your code we might be able to see something.
I suspect it has more to do with "how" I am using this code than anything else. I wouldn't be able to post all of the code because alot of it belongs to vb.
Here is the entire concept:
I have created a new tab using the method mentioned in my previous post that calls a secondary instance of the "friends" tab. On my dev profile I have my new friend tab (and the original doesn't display based on a conditional). The customized friend tab templates are renames of the originals but have allowed me to manipulate them in a manner fluent with what I am trying to achieve.
I currently have my friends showing their instant message icons if they are using them beside their avatar. This makes reaching them pretty easy for me. I am looking to add the custom facebook field to that list so that I can access their facebook directly from my friends list as well.
Essentially I would be able to pull this off if I could get the field to show on the friends tab since I am using the same code.
--------------- Added 1331472906 at 1331472906 ---------------
Anyone have any ideas for me to get this to work? I wasted a few more hours yesterday trying to figure it out to no avail.
stoute
09-01-2013, 09:42 PM
I'm trying to do something similar... did you ever find out how to get profile fields to display on the added tab in the member.php page
RickyH
09-02-2013, 10:20 AM
You would have to edit the memberdisplay template to have the <vb:if condition> code, i'll find it from one of my previous posts for you and add to this reply.
Edit: Code is;
<vb:if condition="$post['field5']">Field 5:{vb:raw post.field5}</vb:if>
stoute
09-09-2013, 10:06 PM
strangely enough that didn't display anything for me.
tbworld
09-09-2013, 11:11 PM
I would have to see your code to see what you are doing wrong. If you care to post it then I would be glad to help.
The $post variable in general is not usually available to the templates in whole, although I have not looked at the code in the profile tabs. My two cents.
stoute
09-09-2013, 11:28 PM
New custom Tab template:
<div id="view-my_character_bio" class="<vb:if condition="$selected_tab == 'my_character_bio'">selected_view_section<vb:else />view_section</vb:if><vb:if condition="$userinfo['userid'] != $bbuserinfo['userid']"> vm_other_prof</vb:if>">
<div class="blocksubhead subsectionhead userprof_headers userprof_headers_border">
<h4 class="subsectionhead-understate">My Character's Bio</h4>
</div>
<div style="margin-left:25px;margin-right:25px">
<br />This is a <b>custom tab</b> test.<br />
Code should appear below.<br/>
<vb:if condition="$post['field5']">Field 5:{vb:raw post.field5}<br/></vb:if>
Code should appear above.
</div>
</div>
Plugin to show the custom tab:
if (isset($vbulletin->GPC['tab']))
{
$selected_tab = $vbulletin->GPC['tab'];
}
$blockinfo['title'] = "My Bio";
$blockid = "my_character_bio";
$taburl = $memberurl = fetch_seo_url('member', $prepared) . "&tab=my_character_bio#my_character_bio";
$templater = vB_Template::create('memberinfo_tab');
$templater->register('selected_tab', $selected_tab);
$templater->register('relpath', $relpath);
$templater->register('blockinfo', $blockinfo);
$templater->register('blockid', $blockid);
$templater->register('taburl', $taburl);
$template_hook['profile_tabs_first'] .= $templater->render();
// ### Your code to fill the tab ###
// Don't forget you need to register any variables for use in templates
$templater = vB_Template::create('my_character_bio');
$templater->register('selected_tab', $selected_tab);
$template_hook['profile_tabs'] .= $templater->render();
plugin to make custom tab default:
if (!$vbulletin->GPC_exists['tab'])
{
$vbulletin->GPC['tab'] = 'my_character_bio';
}
here is the live link: http://immortalarg.com/forum/member.php?1-stoute
ozzy47
09-09-2013, 11:31 PM
And what plugin location are you using to execute the two above?
stoute
09-09-2013, 11:42 PM
sorry, I should have added that.
Plugin to show the custom tab: member_complete
Plugin to make custom tab default: member_build_blocks_start
cellarius
09-10-2013, 12:15 PM
Use $prepared instead of $post. $post is not available to the member profile templates.
tbworld
09-10-2013, 02:51 PM
@Cellarius is of course right. You need to use $prepared. You will also need to add your field to the array in 'class_userprofile.php". You should then be able to use it in your template as a conditional. Make sure you register array $prepared in your template or it will not work. Use hook 'member_build_blocks_start' -- which I already think you are using.
Around line #89 in 'class_userprofile.php'
var $auto_prepare = array(
..................
'show',
'field5', //Add your fieldxx here to the bottom of the array.
);
Sorry, I was too tired when I wrote this to see if there was another way to add 'fieldxx' to the 'prepared' array, but at least this will get you started.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.