PDA

View Full Version : ProfileFields


mokonzi
03-14-2010, 08:53 AM
I've been looking for details on how to include profilefield information in templates. It used to be possible by the following commands:

<if condition="$userinfo['fieldxx'] == 8"></if>
$bbuserinfo[fieldx]
$post[fieldx]

etc

I want to utilize some unique profile fields by adding them to the header, but I'm struggling to find out what the new conditional commands are in vb4.

Anyone able to help me out with this? Both the if command and the display command?

donottumbledry
03-14-2010, 12:38 PM
<vb:if condition="$my_php_var"> your HMTL </vb:if>

or

<vb:if condition="$my_php_var == 'my condition' "> your HMTL </vb:if>

where == can be any standard PHP comparator. The $my_php_var can be either a variable or an array so becomes $my_php_var['key'] and so on.

To insert variables into VB4 you need to ensure the variables are registered for the template you wish to use them in. Read this article here for how to do it. Took me a while to get used to the system but now it all makes sense :)

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

mokonzi
03-14-2010, 01:55 PM
Thanks donottumbledry. So is there no way of doing similar to this vB3 article (https://vborg.vbsupport.ru/showthread.php?t=118896) in vB4 without creating a plugin and registering the variables/arrays?

donottumbledry
03-14-2010, 06:16 PM
All user profile fields are automatically available in the postbit template.

You will either need to modify postbit or postbit_legacy depending on what you are using. The variables are available through the following VB variable:

{vb:raw post.field22} where 22 would be whatever the field of your choosing is.


To write a conditional statement to test for the existence of a field then you would write something along the line of:


<vb:if condition = "$post['field22']">
<span class="profile_description">Favourite Colour: </span>
<span class="profile_field">{vb:raw post.field22}</span>
</vb:if>


Obviously you can use whatever tags you wish inside the conditional loop and the CSS styles I chose I just examples, they don't exist in VB by default.

VB4 seems to have a predefined style using <dd> and <dt> tags. If you look closely into the postbit_legacy template you will see that descriptions of the profile fields are wrapped in <dd> tags and the actual data is wrapped in <dt> tags. This seems to automatically give you a nice spaced seperation such as for post count, blog count etc.