View Full Version : Adding a user profile option that controls template outputs
MrEyes
02-27-2008, 01:06 PM
I would like to add a checkbox option to the registered user profiles that will allow them to choose to display the site header banner.
Now I know how to add the new profile option through admin CP.
and I know how to edit the header template to include an if condition check around the header banner html.
What I do not know is what the condition is I am checking.
Could anybody point me in the right direction?
NeuroLancer
02-27-2008, 01:21 PM
The condition you want to check is the profile field, lets say you make a checkbox, if it has value (i.e. its been ticked), display the header.
something like this in your header:
<if condition="$userinfo[fieldx] == 1"> Header code </if>
MrEyes
02-27-2008, 02:14 PM
Thanks for that, just tried it and something has gone a bit odd. Although I originally suggested a check box, I have since decided to use a Single-Selection Menu.
I have added the menu item with two options (Show, Hide), this displays correctly in Profile - Edit Options - Miscellaneous Options. It also seems be accepting saves etc etc. This was added as "field7".
I have then added the following condition around the header logo table:
<if condition="$userinfo[field7] != 'Hide'">
Header code </if>
However this doesnt seem to work, I wasn't sure if using the single quotes around "Hide" was correct so I have also tried without them.
Interestingly if I put the following into the template
<a>X.$userinfo[field7]</a>
it outputs "X." so it seems the field7 value is empty which is why the condition check doesn't work.
If it helps at all, this is how the field is configured:
Title : Show logo header
Description : Some descriptive guff
Profile Field Category : Uncategorised
Options : Show Hide (on seperate lines)
Set Default: Yes, but no first blank option
Display Order : 7
Field Required : No*
Field Editable by User : Yes
Private Field: Yes
Field Searchable on Members List : No
Show on members list : No
Optional Input : No
Display Page : Options: Other
* I selected No for this as I don't want this to be part of registration, rather an option that a registered user can select once they are part of the forum.
Any ideas?
Opserty
02-27-2008, 02:46 PM
$bbuserinfo not $userinfo
MrEyes
02-27-2008, 03:04 PM
$bbuserinfo not $userinfo
You are beautiful
NeuroLancer
02-27-2008, 05:56 PM
aha whoops yes... Using bbuserinfo is for the logged in user, userinfo would be for say someone elses profile data and so on. glad its sorted.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.