<?php

/*
 * Page default template
 *
 * @package far_loop
 *
 */

get_header();

$fields = array_fill_keys( array(
	'sections',
), null );

foreach ( $fields as $field => $value )
	$fields[$field] = get_field( $field );

?>

<div class="u_pt-3 u_pt-md-6">
    <div class="l_container u_mv-5">
      <!-- page-title module-->
      <div class="page-title u_mb-3 u_mb-md-4">
        <!-- Page title-->
        <h1 class="page-title__apex-title u_mb-0p5"><?php the_title();?></h1>
      </div>
      <!-- share-module-->
      <?php share_module();?>
      
      <div class="grid u_mh-min1p5 u_mt-md-4">
        
        <?php if ( !empty( $fields['sections'] ) ) :?>
        
        <div data-sticky-sidebar class="col--sm--two--fifth col--md--one--third u_ph-1p5">
          <ul class="side-nav">
	          
            <?php foreach ( $fields['sections'] as $section ) : ?>
            
            <li class="side-nav__item"><a class="side-nav__link" href="#<?php echo sanitize_title( $section['section_title'] );?>" data-soft-scroll="#<?php echo sanitize_title( $section['section_title'] );?>"><?php echo $section['section_title'];?></a></li>
            
            <?php endforeach; // section ?>
            
          </ul>
        </div>
        <div class="col--sm--three--fifth col--md--two--third u_ph-1p5">
	      
	      <?php foreach ( $fields['sections'] as $section ) : ?>
          
          <div id="<?php echo sanitize_title( $section['section_title'] );?>" class="visitors-section">
            <h2 class="visitors-section__section-heading"><?php echo $section['section_title'];?></h2>
            
            <!-- wysiwyg module-->
            <div class="wysiwyg">
              <!-- wysiwyg text block-->
              <?php echo $section['section_content'];?>
            </div>
          </div>
          
          <?php endforeach; // section ?>
			
			
	<?php if( have_rows('documents') ) : ?>
  <div class="documents-section u_mt-4 u_ph-1p5">
    
    <ul class="documents-list">
      <?php while( have_rows('documents') ) : the_row(); 
        $title = get_sub_field('document_title');
        $file = get_sub_field('document_file');
        if( $file ) :
      ?>
        <li class="documents-list__item">
          <a href="<?php echo esc_url($file); ?>" target="_blank" class="documents-list__link">
            <?php echo esc_html($title); ?>
          </a>
        </li>
      <?php endif; endwhile; ?>
    </ul>
  </div>
<?php endif; ?>
			
			

			
			
        </div>
        
        <?php endif; //sections ?>
        
      </div>
    </div>
  </div>

<?php

get_footer();