The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
Hi, I have setup a radio button custom field. In my postbit template I'd like to add some code that shows a line of text next to each users post depending on what option they have selected in the custom field.
Basically the logic is: If the user who made this post has option 1 set then show [this piece of code]. If they have option 2 selected then show [this other piece of code]. Can anyone help me write that? |
|
#2
|
|||
|
|||
|
It should be something like:
Code:
<vb:if condition="$post['fieldX'] == 1"> Something <vb:else /> Something else </vb:if> and of course you'd use the actual field number in place of X. |
|
#3
|
|||
|
|||
|
Thanks for the quick response, I can't seem to get that code working though. Here's what I have:
A custom field, of 'single-selection radio button' type. It has three options 'one', 'two' and 'three. The code I added to my postbit template: PHP Code:
|
|
#4
|
|||
|
|||
|
Oh, right. If the options are 'one', 'two' and 'three' then you have to check for those strings, like
Code:
<vb:if condition="$post['field13'] == 'one'">
One selected
<vb:elseif condition="$post['field13'] == 'two'" />
Two selected
<vb:else />
Something other than one or two selected
</vb:if>
Edit: also there's an elseif you can use, I changed the above to show how you'd use it. |
|
#5
|
|||
|
|||
|
Ah, sorry I should have been clearer from the start. I also noticed I'd nested my if statements incorrectly. The final snippet I used looks like:
PHP Code:
|
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|