Support

Account

Home Forums Add-ons Repeater Field ACF Checkbox display

Solved

ACF Checkbox display

  • I have an Advanced Custom Field (repeater) setup. In the admin area of the page where these custom fields live are 3 options (Standard, Professional and Enterprise). It’s setup so you can see what features are built in to each level of subscription. So there’s 15 features. The Standard feature has the first 10 included. The Professional feature has the first 10 (as in the Standard) plus the next 3 features. The Enterprise level has the first 10 (as in the Standard) plus the 3 that the Professional level has and the last 2 features (only the Enterprise has the last 2 features).

    I’ve been searching and trying many different things but cannot get what I’m after. I’m programming the page in 3 blocks on mobile to match the 3 levels. The first block will represent the Standard level and will list all 10 features it has. The next block will house the Professional level but instead of listing all the duplicate 10 that Standard has, it will read, “Same features as Standard, plus”, then it will list the next 3 associated with the Professional level. Then comes the Enterprise level block. This will also read, ” Same features and Standard and Professional, plus”… then it will list the last two features.

    I’m having a real hard time getting the display to only display the features for Professional and Enterprise.

    The code below is what I have now but because Enterprise has all of those features, it displays them all instead of just the features that only have Enterprise. The same with Professional. They are both displaying all the features that Standard has too because they all have them. I just cannot figure out the right check to only display the new features that the other doesn’t have.

    Here is my bit of code for Professional:

    `<?php $professional = get_sub_field(‘feature_software_version’); ?>
    <?php if( in_array(‘professional’, $professional) ) { ?>
    <span class=”featureshead”><?php the_sub_field(‘feature_headline’); ?></span><br />
    <?php } else { ?>
    <?php } ?>`

    Here is my bit of code for Enterprise:

    `<?php $enterprise = get_sub_field(‘feature_software_version’); ?>
    <?php if ( in_array(‘enterprise’, $enterprise ) ) { ?>

    <span class=”featureshead”><?php the_sub_field(‘feature_headline’); ?></span><br />

    <?php } else { ?>
    <?php } ?>`

  • I don’t know if this is going to make any sense to you or not but…

    I would set up another array to hold a list of the features that I’ve already shown. Then I’d check each feature to see if it’s already in that array and if it is I’d skip it. As I display each feature for a package I’d add an entry to this new array so that it’s not shown again.

    Hope that helps.

  • Thanks for the idea John! I ended up outputting what each array was defining and then went from there. It worked out great.

    Here’s my code for Professional:

    <?php $enterprise = get_sub_field('feature_software_version'); ?>
    	<?php if ( $enterprise[0] === 'professional') {?>
    		<li><?php the_sub_field('feature_headline'); ?></li>
    											<?php } else {
    }?>

    Here’s my code for Enterprise:

    <?php $enterprise = get_sub_field('feature_software_version'); ?>
    	<?php if ( $enterprise[0] === 'enterprise') {?>
    		<li><?php the_sub_field('feature_headline'); ?></li>
    
    <?php } else {
    }?>

    Then above I just placed some text that reads, “Includes features of Standard‘ and in Enterprise, the same but Standard and Professional.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘ACF Checkbox display’ is closed to new replies.