Log in

View Full Version : Adding a custom field under the avatar


j1mmy
10-27-2011, 09:14 PM
How can I add a custom field detail for viewing under the avatar next to join date, and post count?

Thanks

kh99
10-27-2011, 10:18 PM
Are you talking about a custom profile field? You just need to add the field in the adminCP, then edit the postbit or postbit_legacy template and add $post[fieldX] where you want it to appear (of course you'd change X to the actual id number of your custom field).

j1mmy
10-28-2011, 04:35 PM
Yes a custom profile field.

Do I edit both templates or just any of those two?

kh99
10-29-2011, 12:06 AM
You would edit the one you're using. (There's a "Use Legacy (Vertical) Postbit Template" setting in the adminCP options, under "Help Style & Language Settings"). Basically, if you have all the poster's info on the left side then you're using postbit_legacy. If it's across the top (like this site) then it's postbit.

BTW, in my previous post I orignially had vb4 syntax for adding the variable to the template, but I just fixed it. Sorry if that caused you any problems.

j1mmy
10-29-2011, 08:56 PM
OK, so I've found the template, and I guess this is what I need to focus on?

<div class="smallfont">
&nbsp;<br />
<if condition="$post['joindate']"><div>$vbphrase[join_date]: $post[joindate]</div></if>
<if condition="$post['field8']"><div>$vbphrase[location_perm]: $post[field8]</div></if>
<if condition="$post['age']"><div>$vbphrase[age]: $post[age]</div></if>
<div>
$vbphrase[posts]: $post[posts]
</div>

Also do you know I can get rid of age showing up without deleting that line in the code? Is there an option?

kh99
10-29-2011, 11:52 PM
Yes, that's the place, you should just be able to copy one of those lines and make your changes (you don't even have to make a phrase if you don't want to, you can just put your text in there).

I think a user can choose whether or not to have their age displayed, but I don't think there's a global setting. If you dont' want to take it out because you're concerned about figuring out how to replace it, you could do this:

<if condition="0">
<if condition="$post['age']"><div>$vbphrase[age]: $post[age]</div></if>
</if>

j1mmy
10-30-2011, 12:05 PM
Thanks. This is how I am putting the code in, but the Occupation starts on the same line as the Education:

<strong>Education & Occupation</strong><br />
Education: $post[field11]
Occupation: $post[field14]


Do I need to wrap them in div tags as is done with the vB default ones?

--------------- Added 1319977871 at 1319977871 ---------------

Also, I've noticed that as I allow unregistered users to post on my board, their post count comes up as n/a. How can I do the same with the custom fields? How can I get them to also show n/a when a guest posts? At the moment its blank.

kh99
11-02-2011, 12:44 PM
Thanks. This is how I am putting the code in, but the Occupation starts on the same line as the Education:

<strong>Education & Occupation</strong><br />
Education: $post[field11]
Occupation: $post[field14]


Do I need to wrap them in div tags as is done with the vB default ones?


You need to use <BR /> to make a new line in html. A div would do it too I think.


--------------- Added 1319977871 at 1319977871 ---------------

Also, I've noticed that as I allow unregistered users to post on my board, their post count comes up as n/a. How can I do the same with the custom fields? How can I get them to also show n/a when a guest posts? At the moment its blank.


You can do this:

<if condition="$show['member']">code for member<else />code for guest</if>