Scott_Sanders_wpb
12/4/2019 - 1:36 AM

animated blocks

function services_animated_blocks($pagestyle) {
    $repeater = 'animated_blocks_' . $pagestyle;
    $counter = 1;
    $listrepeater = 'list_items';
    $imageorder = 1;
    $textorder = 2;
    $output = '';
    
    if (is_page() ) {
        $offset = '';
    } else {
        $offset = 'services-content-offset ';
    }
    
    if( have_rows($repeater) ):
        
        if ( get_field('animated_blocks_image_' . $pagestyle) ) { $image = get_field('animated_blocks_image_' . $pagestyle); }
        
        $output .= '<div class="animated-blocks-background ' . $offset . 'grid-container full" ';
        $output .= 'style="background-image: url(\'' . $image . '\');">';
        if ( get_field('animated_blocks_header_' . $pagestyle) ) { 
            $header = get_field('animated_blocks_header_' . $pagestyle);
            $output .= '<h2 class="animated-blocks-header">' . $header . '</h2>';
        } 
            $output .= '<div class="animated-blocks-container grid-container">';
                while ( have_rows($repeater) ) : the_row();
                    if ( $counter <= 9 ) { $countertext = '0' . $counter; } else { $countertext = '' . $counter; }
                    $blurb = get_sub_field('blurb');
                    $boxcontent = get_sub_field('content');
                    $title = get_sub_field('title');
                    $buttontext = get_sub_field('button_text');
                    $buttonlink = get_sub_field('button_link');
                    $closer = get_sub_field('closer');
                        //$bgposition = '0';
                    if ($imageorder == 2) { $bgposition = '100'; $icon = $icon2; }
                    
                    $output .= '<div class="animated-blocks grid-x grid-padding-x">';
                        $output .= '<div class="title-panel large-4 large-order-' . $imageorder . ' medium-4 medium-order-' . $imageorder . ' small-6 small-order-' . $imageorder . ' cell">';
                            $output .= '<div class="grid-y">';
                                $output .= '<div class="hollow-number large-3 medium-3 small-3 cell">';
                                    $output .= '<span>' . $countertext . '</span>';
                                $output .= '</div>';
                                $output .= '<div class="title large-3 medium-3 small-3 cell">';
                                    $output .= '<h2>' . $title . '</h2>';
                                $output .= '</div>';
                                $output .= '<div class="blurb large-6 medium-6 small-6 cell">';
                                    $output .= $blurb;
                                $output .= '</div>';
                            $output .= '</div>';
                        $output .= '</div>';
                        $output .= '<div class="content-panel large-8 large-order-' . $textorder . ' medium-8 medium-order-' . $textorder . ' small-6 small-order-' . $imageorder . ' cell">';
                            $output .= '<p>' . $boxcontent . '</p>';
                            if ( ($buttontext = get_sub_field('button_text')) && ($buttonlink = get_sub_field('button_link')) ) {
                                $output .= '<a class="button" target="_blank" href="' . $buttonlink . '">' . $buttontext . '</a>';
                            }
                            if ( $closer = get_sub_field('closer') ) {
                                $output .= '<p><strong>' . $closer . '</strong></p>';
                            }
                        $output .= '</div>';
                    $output .= '</div>';    
                    
                           
                    if ( $imageorder == 1) {
                        $imageorder = 2;
                        $textorder = 1;
                    } else {
                        $imageorder = 1;
                        $textorder = 2;
                    }
                    $counter++;
            endwhile;
            $output .= '</div>';
        $output .= '</div>'; 
    endif;
return $output;
}