PDA

View Full Version : OR condition in VB


scottkoz20
02-10-2018, 12:42 PM
I did a postbit_legacy change this morning to recreate member social networking and related hobby site accounts to their profile on my site.

In this, I added "Find me on:" which will then show all of the social accounts

However, I don't want the "Find me on:" to appear if they choose to not provide anything.


SO, I did add the following, and tied it to one of the profile fields used for this

<vb:if condition="$post['field32']">
<B><SIZE=5>Find me on:<br /></B><?SIZE></vb:if>


Here is a visual
https://www.sportscardforum.com/attachment.php?attachmentid=137050&d=1518271792

The problem is if they dont link their Twitter account (Field32 on my site), the verbiage does not appear

Thus, my thinking on using an OR condition with the fields, but I am not 100% sure if I can array this in the following manner

<vb:if condition="in_array($post['field'], array(32,X,Y))">

or if there would be a better route for this handling this

Dave
02-10-2018, 12:51 PM
So you want to check if field32 is filled in or not?
Simply use <vb:if condition="!empty($post['field32'])">not empty</vb:if>

scottkoz20
02-10-2018, 12:57 PM
I have at this point 10 fields that I would want to do this same check for... though in thinking about this, it might be best to only tie this to a single field or 2.

Dave
02-10-2018, 01:08 PM
You'd have to use the !empty check for each one of those individually in order to do what you want. The in_array function you showed in your example checks if $post['field'][32] exists which makes no sense so that cannot be used.

scottkoz20
02-10-2018, 01:20 PM
Thanks Dave - i figured the array was not the correct method for this.