Support

Account

Home Forums Add-ons Repeater Field True / False question

Solving

True / False question

  • I have custom field group (repeater) on page A, one of those fields is a “True / False” box.

    What is the best way if when checked “True” all of the content from that field group post, displays on page B and does not display on page A?

  • Hi @bgomski

    Can you please edit the above to clearly describe the issue. There are many parts to your query that are confusing:

    1. I have custom field group (repeater) on page A
    Is this a field, or a field group?

    2. one of those fields is a “True / False” box.
    Is this a sub field or normal field?

    3. What is ‘all of the content from that field group post’

    4. What is page B?

    5. How do you access page A and page B?

    6. How does page B know of page A?

    Thanks
    E

  • 1. Repeater field with a text sub-field type and a true_false sub-field.

    2. this is a sub-field

    3. the content entered in the text field.

    4. Page B is a wordpress page which wont have any user content loaded from the standard wordpress CMS or any fields shown from ACS. The data from 1 row of the repeater on page A will auto populate on page B if the true_false checkbox is checked in that row.

    5. Page A is accessed from a link on the website. Page B will be accessed from a link on page A.

    6. The content in the subfields in the repeater will either post to page A or B depending on if the checkbox is checked. But all of the rows will always be managed from a “wordpress page” in the wordpress admin. I am using a rule to show if field group is equal to page A.

    Hopefully this clarified everything.

  • Hi @bgomski

    So essentially, you care trying to manage all page’s content via a repeater field on Page A?

    When on Page B, you can load all of Page A using the get_field function. Please note you will need to include the $post_id parameter to point to Page A.

    Now that you have Page A data, you can loop through the rows. You have a true/false field and a text field, so just loop over the rows and if the checkbox field is ticked, then use the text value.

    Easy.

    Please read the repeater field docs to get a better idea of the code.

    Thanks
    E

  • I understand getting page A data and the $post_id parameter. I think now I am confused on how page B will actually display that data on the page. All of my other custom field content uses the Location and Rules to display. So what PHP would I add to my template file that says:

    on page B post the following:

    <?php if( have_rows('active_studies', 14) ): ?>
     
    <?php while ( have_rows('active_studies') ) : the_row(); ?>
    
    <h1><?php the_sub_field('title'); ?></h1>
    <h2><?php the_sub_field('investigator_name'); ?></h2>
    <h2><i><?php the_sub_field('organization(s)'); ?></i></h2>
    <p><?php the_sub_field('summary'); ?></p>
    <h3><?php the_sub_field('related_content_title'); ?></h3>
    <p style="color: #666666;"><?php the_sub_field('related_content'); ?></p>
    
    <?php endwhile;
     
    else :
     
        // no rows found
     
    endif;
     
    ?>
    
  • I am close to a solution, I have the true/false working but need the else piece of the puzzle to post to page id 235. any idea?

    <?php if( have_rows('active_studies', 14) ): ?>
     
    <?php while ( have_rows('active_studies', 14) ) : the_row(); ?>
     
    <?php
    // check if box is ticked
    
    if( get_sub_field('complete_study') )
    {
        echo '<h1>'.the_sub_field('title').'</h1>',
             '<h2>'.the_sub_field('investigator_name').'</h2>',
    	 '<h2><i>'.the_sub_field('organization(s)').'</i></h2>',
    	 '<p>'.the_sub_field('summary').'</p>',
    	 '<h3>'.the_sub_field('related_content_title').'</h3>',
             '<p style="color: #666666;">'.the_sub_field('related_content').'</p>';
    }
    else 
    {
    echo "do something else";
    }
    
    ?>
    
    <?php endwhile;
     
    else :
     
        // no rows found
     
    endif;
     
    ?>
     
  • Hi @bgomski

    
    else 
    {
        echo get_field('the_other_page_title', 235);
    }
    

    Hope that helps.

    Thanks
    E

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

The topic ‘True / False question’ is closed to new replies.