View Full Version : Calling profile field in template question
Boofo
04-21-2011, 04:25 AM
I am trying to called a profile field that is a setting and I can't for the life of me get it to work in a template. This works in PHP:
if ($vbulletin->userinfo["field{$vbulletin->options['boofo_link_1_name']}"])
But how do I do the same thing in a template? The option setting is set to the profile field number. I have tried the following and all I get are template errors:
<vb:if condition="$vbulletin->userinfo['field[$vboptions[boofo_link_1_name]']">
<vb:if condition="$vbulletin->userinfo["field{$vbulletin->options['boofo_link_1_name']}"]">
Lynne
04-21-2011, 04:10 PM
You are missing brackets in the first one:
<vb:if condition="$vbulletin->userinfo['field[$vboptions[boofo_link_1_name]']">
should be:
<vb:if condition="$vbulletin->userinfo['field[$vboptions[boofo_link_1_name]']']">
Boofo
04-21-2011, 04:55 PM
Duh on me. Thank you, Lynne. ;)
EDIT: That doesn't work either Lynne, I get the compilation error.
Lynne
04-21-2011, 10:04 PM
Hmmm, I don't know off the top of my head what it is, but I'm pretty sure I have struggled through something like that before. I did notice you are using $vbulletin->userinfo and you should be using $bbuserinfo instead. So maybe that will help.
Boofo
04-22-2011, 01:04 AM
I tried bbuserinfo before and was getting the same errors.
Zachery
04-22-2011, 01:17 AM
What is the template?
Boofo
04-22-2011, 01:56 AM
It would be the header template, in this scenario. But the compilation error wouldn't have anything to do with $$bbuserinfo or $vbulletin->userinfo, anyway, would it?
Boofo
04-27-2011, 05:45 PM
No one has any idea on this?
Zachery
04-27-2011, 06:42 PM
What happens if you just try to print the varible in the template, does it show anything?
Boofo
04-27-2011, 07:32 PM
I never get that far as I get a template compilation error.
Zachery
04-27-2011, 09:32 PM
{vb:raw bbuserinfo.field$vboptions[boofo_link_1_name]}
Give that a try..
Boofo
04-27-2011, 10:00 PM
That showed up fine in the header. Well, actually this did, but it is also a profile field. I'm not using boofo_link_1_name anymore.
{vb:raw bbuserinfo.field$vboptions[boofo_uhg_field]}
So, how do we use this in a conditional in the template?
How about:
<vb:if condition="$vbulletin->userinfo['field[' . $vboptions['boofo_uhg_field'] . ']']">
Boofo
04-27-2011, 10:16 PM
Almost got it. But it only seems to work if I do a NOT condition, like this:
<vb:if condition="!$vbulletin->userinfo['field[' . $vboptions['boofoboofo_uhg_field'] . ']']">
<li>{vb:rawphrase no_new_messages}</li>
</vb:if>
Then the phrase shows. But since there is a viable field for that, it should work the other way around, shouldn't it?
No more template error, though, so thank you for that.
EDIT: I see what it is. You added and extra boofo in the filed name.
EDIT: I see what it is. You added and extra boofo in the filed name.
Oh yeah sorry. I took it out a minute later but I guess you had seen it already.
Boofo
04-27-2011, 10:24 PM
Nope, still not picking it up unless I do the NOT condition.
Yeah, I guess that means it's not coming out to the right variable name. OK, maybe this?
<vb:if condition="$vbulletin->userinfo['field' . $vboptions['boofo_uhg_field']]">
ETA: or this
<vb:if condition="$vbulletin->userinfo['field' . $vbulletin->options['boofo_uhg_field']]">
Boofo
04-27-2011, 10:33 PM
Bingo! We have a winner! ;)
You are the man!
--------------- Added 1303967314 at 1303967314 ---------------
Thank you, Kevin, for the fix. Your first one worked in post #17. I haven't tried the second one yet. But I would think it would work, also.
And kudos to you, too, Zach, for the code to test in the template.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.