PDA

View Full Version : Displaying text color in postbit?


Max Taxable
05-17-2014, 12:59 AM
Playing around with custom profile fields, installing the ability for users to choose their gender. It works, but I think I want a postbit template conditional for making it display blue if they chose Male, and pink if they chose female.

Right now it displays like this:

https://vborg.vbsupport.ru/external/2014/05/22.jpg

Here's the bit from the postbit template, where we're calling this up:<vb:if condition="$post['field12']"><dt>Gender</dt> <dd>{vb:raw post.field12}</dd></vb:if>

Any ideas? I want it to go more like "if gender =1 then blue and if gender =2 then pink"

kh99
05-17-2014, 09:48 AM
I guess you want something like:
<vb:if condition="$post['field12']"><dt>Gender</dt> <dd style="color:<vb:if condition="$post['field12'] == 'Male'">blue<vb:else />pink</vb:if>" >{vb:raw post.field12}</dd></vb:if>

Max Taxable
05-17-2014, 12:26 PM
That sure looks like it might work... I will have it tried and let you know.

Thanks Kevin!

Max Taxable
05-17-2014, 12:56 PM
"Invalid tag nesting" error.

kh99
05-17-2014, 01:57 PM
Yeah, there were a couple of problems with that. I shouldn't even try to post things without testing them first, I don't have a very good record. Anyway, I tried it and posted the fixed code above.

Max Taxable
05-17-2014, 02:19 PM
U Da Man, thank you again!

Max Taxable
05-17-2014, 07:11 PM
We made the color "HotPink" to get it to stand out more. Nicely done Kevin and again, thank you for the help.

kh99
05-17-2014, 10:36 PM
Probably the "right" way to do it would be to change it to set a class based on the gender, then put CSS in additional.css to set the colors (and/or font, size, etc). Also that way you could have different colors per style if you wanted. But if it's doing what you want the way it is, I'd say that's fine.

Max Taxable
05-18-2014, 01:03 AM
Probably the "right" way to do it would be to change it to set a class based on the gender, then put CSS in additional.css to set the colors (and/or font, size, etc). Also that way you could have different colors per style if you wanted. But if it's doing what you want the way it is, I'd say that's fine.I thought of that as well, but it was not as simple for the person I'm helping, and very difficult to explain.

This works for what they want, job well done.