Support

Account

Home Forums General Issues Flexible content within repeater field

Unread

Flexible content within repeater field

  • Hi

    I’m having trouble with a nested loop. I have a repeater field with a flexible content field nested inside, but a can’t get it working.

    My website loads everything that comes before this section, but not the section with the nested loop or anything that comes after. The section looks like this:

    <div class="carousel-graphs-sm opacity-zero" style="margin-top: 0px;">
                        <?php
                        // check if the repeater field has rows of data
                        if( have_rows('slider_med_grafer') ) {
    
                            // loop through the rows of data
                            while ( have_rows('slider_med_grafer') ) : the_row();
                        ?>
                            <div class=""> 
                                <div>
                                    <div class="container-fluid">
                                        <div class="row" style="margin-bottom: 50px;">
                                        
                                            <?php
                                            // check if the flexible content field has rows of data
                                            if( have_rows('grafer') ) {
                                                $countbar = 1;
                                                $count = count( get_sub_field('grafer') );
                                                if($count == 1 ) {
                                                    $col-md = 'col-md-4 col-md-offset-4';
                                                } elseif( $count = 2 ) {
                                                    $col-md = 'col-md-4 col-md-offset-2';
                                                } elseif( $count == 3) {
                                                    $col-md = 'col-md-4';
                                                } elseif( $count == 4 ) {
                                                    $col-md = 'col-md-3';
                                                };
                                                 // loop through the rows of data
                                                while ( have_rows('grafer') ) : the_row();
    
                                                    if( get_row_layout() == 'barchart' ) {
                                            ?>
    
                                                        <div class="col-xs-12 <?php echo $col-md; ?>">
                                                            <div class="chart bar-<?php echo $countbar; ?>">
                                                               
                                                               <?php 
                                                                $procentikkeanbragt = get_sub_field('procentsats_ikke_anbragte');
                                                                $procentanbragt = get_sub_field('procentsats_anbragte');
                                                        
                                                                if( $procentikkeanbragt > $procentanbragt ) {         
                                                                    $maxprocent = $procentikkeanbragt;
                                                                } else { 
                                                                    $maxprocent = $procentanbragt;
                                                                }; 
                                                                ?>
                                                               
                                                               
                                                                <div class="bar-chart first" data-bars="[<?php the_sub_field('procentsats_ikke_anbragte'); ?>,<?php the_sub_field('procentsats_anbragte'); ?>]" data-max="<?php echo $maxprocent; ?>" data-unit="%" data-width="60">
                                                                    <p class="bartext-left">
                                                                        Ikke-anbragte
                                                                    </p>
                                                                    <p class="bartext-right">
                                                                        Anbragte
                                                                    </p>
                                                                    <p class="bar-caption">
                                                                        <?php the_sub_field('tekst'); ?>
                                                                    </p>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        
                                                        <?php $countbar++; ?>
                                                       
                                                       
                                                        
                                            <?php
                                                    } elseif( get_row_layout() == "donutchart" ) { 
                                            ?>
                                                        <?php 
                                                        if( get_sub_field('procentsats') < 10 ) {
                                                            $procent = "0.0" . get_sub_field('procentsats');  
                                                        } elseif( get_sub_field('procentsats') = 100 ) {
                                                            $procent = "1";
                                                        } else {
                                                            $procent = "0." . get_sub_field('procentsats');
                                                        };
                                                        ?>
                                                        <div class="col-xs-12 <?php echo $col-md; ?>">
                                                            <div class="chart donut">
                                                                <div class="donut-chart fill uanimated" data-percent="<?php echo $procent; ?>" data-title="%">
                                                                    <p class="circle-caption">
                                                                        <?php the_sub_field('tekst'); ?>
                                                                    </p>
                                                                </div>
                                                            </div>
                                                        </div>
    
                                            <?php
                                                    } else {
                                                // no layouts found
                                            };
                                                endwhile;
                                            
                                            ?>
                                        
                                        
                                        
                                        
                                        </div>
                                        <div class="row">
                                            <div class="col-xs-12">
                                                <p class="text-center kilde-tekst">
                                                    Kilde: <?php the_sub_field('kilde'); ?>
                                                </p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>     
                        <?php   
                                };
                            endwhile;
                        } else {
                            // no rows found
                           };
                        ?>            
                </div>
Viewing 1 post (of 1 total)

The topic ‘Flexible content within repeater field’ is closed to new replies.