vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Profile Field Value (https://vborg.vbsupport.ru/showthread.php?t=279838)

Rich 03-09-2012 07:53 PM

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:

Code:

<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.

kh99 03-09-2012 07:56 PM

Did you try {vb:raw userinfo.field281} ?

Rich 03-09-2012 08:09 PM

I may have, it didn't work when I just tried it. I also wanted to wrap it in an if conditional like so:

HTML Code:

<vb:if condition="$userinfo['field281']">
$userinfo['field281']
</vb:if>


kh99 03-09-2012 08:34 PM

How did you create your new tab?

Rich 03-09-2012 08:45 PM

I followed this:

https://vborg.vbsupport.ru/showthread.php?t=265971

kh99 03-09-2012 08:51 PM

Oh, OK, I think you need to register $userinfo for use in your custom template, like this:

Code:

$templater->register('userinfo', $userinfo);

[S]then I think what you have in post #3 should work.[/S] The condition you have in post #3 should work, but you need {vb:raw userinfo.field281} inside the if.

Rich 03-10-2012 11:54 AM

I tried this as well. I can get it to work with

Code:

<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

kh99 03-10-2012 12:19 PM

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.

Rich 03-10-2012 12:29 PM

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 [DATE]1331472906[/DATE] at [TIME]1331472906[/TIME] ---------------

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 08: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 09: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;
Code:

<vb:if condition="$post['field5']">Field 5:{vb:raw post.field5}</vb:if>

stoute 09-09-2013 09:06 PM

strangely enough that didn't display anything for me.

tbworld 09-09-2013 10: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 10:28 PM

New custom Tab template:
Code:

<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:
Code:

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) . "&amp;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:
Code:

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 10:31 PM

And what plugin location are you using to execute the two above?

stoute 09-09-2013 10: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 11:15 AM

Use $prepared instead of $post. $post is not available to the member profile templates.

tbworld 09-10-2013 01: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'
Code:

    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.


All times are GMT. The time now is 04:37 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02274 seconds
  • Memory Usage 1,758KB
  • 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
  • (8)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete