Advanced Custom Fields

<?php /* Template Name: Text Header */ ?>

<?php get_header(); ?>
    <?php $header_bg  = get_header_bg(); ?>
    <?php $title_icon = get_field('header_supporting_icon')['url']; if (!empty($title_icon)) { $title_icon_bg = "background-image: url($title_icon);"; $header_class = "has_title_icon"; } ?>
    <?php $mobile_header = get_field('mobile_header')['url']; if (!empty($mobile_header)) { ?> 
	    <style>
			@media (max-width: 900px) { /* *************** */
			.bg-cover.page_header {
				background-image: url('<?php echo $mobile_header; ?>') !important;
			}
			} /* *************** */
	    </style>
    <?php } ?>
    
	<div class='popup_block'>
		<div class='popup_wrap ca'>
			<div class='popup_off_block'><span id='lw_popup_off'>&#x2715;</span></div>
			<div id='popup_content'></div>
		</div>
	</div>
    
    <div class='bg-cover page_header <?php echo $header_class; ?> <?php echo get_field('font_size'); ?>' style="<?php echo $header_bg; ?>">
	    <?php $icon_header_color = get_field('icon_header_color'); if (!empty($icon_header_color)) { $header_bg_color = "background-color: $icon_header_color;"; } ?>
		<div class="grid-container ca">
			<div class="prefix-10 grid-50 suffix-40">
				<h1 style="<?php echo $title_icon_bg; ?>"><?php echo get_field('header_text'); ?></h1>
			</div>
		</div>
        <section id="heading"></section>
    </div>    
    

	<!-- Flexible Content -->
	<?php if( have_rows('flexible_content') ) : ?>

		<?php while ( have_rows('flexible_content') ) : the_row(); ?>
		
			<?php if( get_row_layout() == 'two_column_intro' ) : ?>

				<?php $headline        = get_sub_field('headline'); ?>
				<?php $left_paragraph  = get_sub_field('left_paragraph'); ?>
				<?php $right_paragraph = get_sub_field('right_paragraph'); ?>	
		        <div class="grid-container grid-parent two_column_block">
			        <div class="prefix-5 grid-90 suffix-5">
			        
				        <?php if (!empty($headline)) { ?>
				            <div class='two_column_intro flex-between <?php echo $tci_class; ?>'>
					            <div class='w-65 mw-100'><h2><?php echo $headline; ?></h2></div>
					            <div class='w-35 mw-100'></div> 
					        </div> 
					    <?php } ?>      
						<div class='two_column_intro flex-between <?php echo $tci_class; ?>'>
							<div class='w-65 mw-100'>
								
							    <?php if (!empty($left_paragraph)) { ?><p><?php echo $left_paragraph; ?></p> <?php } ?>
							</div>
							<blockquote class='w-35 mw-100'>
								<?php if (!empty($right_paragraph)) {  echo $right_paragraph;  } ?>					
							</blockquote>
						</div>	             
		             </div>
		        </div>
             
             
			<?php elseif( get_row_layout() == 'stagger_blocks' ) : ?>
			
				<?php $headline     = get_sub_field('headline');        $stagger_class  = " has_headline"; ?>
				<?php $turn_class = "w-40"; $cycle = 0; $index = 0; ?>

		        <div class="grid-container grid-parent">
			        <div class="prefix-5 grid-90 suffix-5 stagger_blocks_wrap">
				        <?php if (!empty($headline)) { ?><h2><?php echo $headline; ?></h2><?php } ?> 
							<?php if( have_rows('blocks') ) : ?>
								<?php while ( have_rows('blocks') ) : the_row(); ?>
								    <?php $image   = get_sub_field('image'); ?>
								    <?php $link    = get_sub_field('link'); ?>
								    <?php $title   = get_sub_field('title'); ?>
								    <?php $text    = get_sub_field('text'); ?>
								    <?php $type    = get_sub_field('type'); ?>
								    <?php $target  = get_sub_field('target'); ?>
								    <?php if ($type == "video" && !empty($link)) {								    
									     if(strpos($link,"youtube")) {
										    $youtube_id     = get_youtube_id($link);
										    $link           = get_embed_url($youtube_id).'?enablejsapi=1&rel=0&autoplay=1';
									     }
								         $data = "data-video='$link'";
								    } ?>
								     
									<?php $cycle++; ?>
								    <?php if ($cycle == 1 ) { ?> 	  
									    <div class='stagger_block flex-between'>
										<?php if ($turn_class == "w-60") {
										       $turn_class   = "w-40"; 
										}else{ $turn_class   = "w-60"; } ?>
									<?php } ?>    
								    
								    
									<div class='<?php echo $turn_class; ?> cycle_<?php echo $cycle; ?> mw-100 <?php echo $type; ?>' <?php echo $data; ?>> 
										<?php if (!empty($link) && $type != "video") { ?><a href='<?php echo $link; ?>' target='<?php echo $target; ?>'><?php } ?> 
										<div class='inner' style="background-image: url(<?php echo $image['url']; ?>);">
											<div class='ca'>
												<?php if (!empty($title)) { ?><div class='stag_title'><?php echo $title; ?></div> <?php } ?>
											    <?php if (!empty($text)) { ?><div class='stag_text'><?php echo $text; ?></div> <?php } ?>
											</div>
										</div>
										<?php if (!empty($link) && $type != "video") { ?></a><?php } ?>
									</div> 
									
									
									<?php if ($cycle == 2) { echo "</div>"; $cycle = 0; } ?>
									<?php if ($turn_class == "w-60") {
									       $turn_class   = "w-40"; 
									}else{ $turn_class   = "w-60"; } ?>
									
								<?php endwhile; ?>
							<?php endif; ?>
							
							<div class='button_block'><a class="button" href="#">Our Partnership Model</a></div>
					</div>
				</div>
				
				
			<?php elseif( get_row_layout() == 'small_services' ) : ?>
			
		        <div class="grid-container grid-parent">
			        <div class="prefix-5 grid-90 suffix-5 small_services_wrap">
			            <div class="flex-between">
							<?php if( have_rows('services') ) : ?>
								<?php while ( have_rows('services') ) : the_row(); ?>
									<?php $icon  = get_sub_field('icon'); ?>
									<?php $text  = get_sub_field('text'); ?>
									<?php $link  = get_sub_field('link'); ?>	
									<a href='<?php echo $text; ?>' class='w-25 small_service ib mw-50' style="background-image: url(<?php echo $icon['url']; ?>);">
										<?php echo $text; ?>
									</a>
								<?php endwhile; ?>
							<?php endif; ?>
					    </div>		
					</div>
				</div>
				
			<?php elseif( get_row_layout() == 'footer_header' ) : ?>
                <?php $text  = get_sub_field('text'); ?>
                <?php $image = get_sub_field('image'); ?>
                <div class="footer_header_block" style="background-image: url(<?php echo $image['url']; ?>);">
			        <div class="grid-container grid-parent">
				        <div class="prefix-5 grid-90 suffix-5 footer_header_wrap">
							<?php if (!empty($text)) { ?><div class='footer_header_text'><?php echo $text; ?></div> <?php } ?>		
						</div>
					</div>
                </div>
                
			<?php elseif( get_row_layout() == 'headline_and_text' ) : ?>
                <?php $headline = get_sub_field('Headline'); ?>
                <?php $text  = get_sub_field('text'); ?>
			        <div class="grid-container grid-parent mp">
				        <div class="prefix-5 grid-90 suffix-5 headline_and_text_wrap">
							<?php if (!empty($headline)) { ?><h2><?php echo $headline; ?></h2> <?php } ?>
							<?php if (!empty($text)) { ?><p><?php echo $text; ?></p> <?php } ?>		
						</div>
					</div>
					
			<?php elseif( get_row_layout() == 'headline_and_image' ) : ?>
                <?php $headline = get_sub_field('headline'); ?>
                <?php $image  = get_sub_field('image'); ?>
			        <div class="grid-container grid-parent mp">
				        <div class="prefix-5 grid-90 suffix-5 headline_and_image_wrap">
							<?php if (!empty($headline)) { ?><h2><?php echo $headline; ?></h2> <?php } ?>
							<?php if (!empty($text)) { ?><p><img src='<?php echo $image['url']; ?>' /></p> <?php } ?>		
						</div>
					</div>
					
			<?php elseif( get_row_layout() == 'border_left_list' ) : ?>
			        <div class="grid-container grid-parent mp">
				        <div class="prefix-5 grid-90 suffix-5 border_left_list_wrap">
				            <div class='flex-between'>
								<?php if( have_rows('items') ) : ?>
									<?php while ( have_rows('items') ) : the_row(); ?>
	                                    <?php $item_text  = get_sub_field('item_text'); ?>
									    <?php if (!empty($item_text)) { ?><div class='item_text ib w-20 mw-50'><?php echo $item_text; ?></div> <?php } ?>
									<?php endwhile; ?>
								<?php endif; ?>
							</div>
						</div>
					</div>
					
			<?php endif; ?>
		<?php endwhile; ?>
	<?php endif; ?>





<?php get_footer(); ?>
Comments