Guest User

ACF - Repeater & Nested Flexible Content

a guest
Aug 14th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. <?php if( have_rows('page_layout_section') ): // check if the repeater field has rows of data ?>
  2.  
  3. <?php while ( have_rows('page_layout_section') ) : the_row(); // loop through the rows of data ?>
  4.  
  5. <?php // Store the variables ?>
  6. <?php
  7. if(get_sub_field('section_background_colour')) {
  8. $colour = get_sub_field('section_background_colour');
  9. };
  10. ?>
  11.  
  12. <?php
  13. if(get_sub_field('section_background_image')) {
  14. $bgImg = get_sub_field('section_background_image');
  15. };
  16. ?>
  17.  
  18. <?php if( have_rows('row') ): // check if the flexible content field has rows of data ?>
  19.  
  20. <div class="section" style="background-color: <?php echo $colour ?>;">
  21.  
  22. <?php while ( have_rows('row') ) : the_row(); // loop through the rows of data?>
  23.  
  24. <?php if( get_row_layout() == 'full_width_row' ): ?>
  25.  
  26. <div class="row row-full-width">
  27. <div class="grid-container">
  28.  
  29. <div class="grid-100 grid-parent">
  30.  
  31. <?php if( isset($bgImg) ) { ?>
  32. <img class="section-bg-img" src="<?php echo $bgImg ?>" />
  33. <?php } ?>
  34.  
  35. <?php the_sub_field('column:_full_width'); ?>
  36. </div>
  37. </div>
  38. </div><!-- / end .row .full_width-->
  39.  
  40. <?php elseif( get_row_layout() == '50_50_row' ): ?>
  41.  
  42. <div class="row row-50-50">
  43. <div class="grid-container grid-parent">
  44.  
  45. <div class="grid-50 tablet-grid-50">
  46.  
  47. <?php if( isset($bgImg) ) { ?>
  48. <img class="section-bg-img" src="<?php echo $bgImg ?>" />
  49. <?php } ?>
  50.  
  51. <?php the_sub_field('column_one'); ?>
  52. </div>
  53. <div class="grid-50 tablet-grid-50">
  54. <?php the_sub_field('column_two'); ?>
  55. </div>
  56. </div>
  57. </div><!-- / end .row .50-50 -->
  58.  
  59. <?php elseif( get_row_layout() == 'circle-layout' ): ?>
  60.  
  61. <div class="row row-circle-layout">
  62. <div class="grid-container">
  63.  
  64. <div class="grid-66 tablet-grid-66 grid-parent">
  65.  
  66. <?php if( isset($bgImg) ) { ?>
  67. <img class="section-bg-img" src="<?php echo $bgImg ?>" />
  68. <?php } ?>
  69.  
  70. <?php the_sub_field('column_one'); ?>
  71. </div>
  72. <div class="grid-33 tablet-grid-33 grid-parent">
  73. <div class="circle">
  74. <div class="circle-content">
  75. <div class="circle-content-inner">
  76. <?php the_sub_field('column_two'); ?>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div><!-- / end .row .circle-layout -->
  83.  
  84. <?php endif; // end if have 'row' ?>
  85.  
  86. <?php endwhile; // end while have 'row' ?>
  87.  
  88. </div><!-- //end .section -->
  89.  
  90. <?php endif; // end flexible field loop ?>
  91.  
  92. <?php endwhile; // end repeater field endwhile loop ?>
  93.  
  94. <?php endif; // end repeater field ('page_layout_section') loop ?>
Advertisement
Add Comment
Please, Sign In to add comment