This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
page-flex-content.php
86 lines (67 loc) · 2.19 KB
/
page-flex-content.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Template Name: Flexible Content
*/
$breadcrumbs = get_field( "breadcrumbs" );
$page_title = get_field( "page_title" );
$completion_time = get_field( "completion_time" );
$time = get_field( "time" );
$sidebar = get_field( "sidebar" );
$sidebar_menu = get_field( "sidebar_menu" );
$has_sidebar = $sidebar && $sidebar_menu ? 'has-flexible-sidebar' : 'no-flexible-sidebar';
get_header('flex-content');
?>
<div class="flex-content <?php echo $has_sidebar; ?>">
<?php if($breadcrumbs) : ?>
<section class="flex-content__breadcrumbs">
<?php if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb( '<div class="flex-content__breadcrumbs__list">','</div>' );
} ?>
</section>
<?php endif; ?>
<?php if($page_title) : ?>
<section class="flex-content__page-title">
<h1><?php the_title(); ?></h1>
<?php if($completion_time && $time) : ?>
<div class="completion-time">
<div class="icon">
<img src="<?php echo get_template_directory_uri(); ?>/assets/images/time.svg" alt="time to complete" />
</div>
<div class="time">
<?php echo $time; ?>
</div>
</div>
<?php endif; ?>
</section>
<?php endif; ?>
<?php if($sidebar && $sidebar_menu) : ?>
<section class="flex-content__sidebar">
<div class="flex-content__sidebar__title">Page Contents</div>
<div class="flex-content__sidebar__title-mobile">Page Contents</div>
<?php if($sidebar_menu) : ?>
<ul class="flex-content__sidebar__links">
<?php $i = 0; ?>
<?php foreach($sidebar_menu as $link) :
$active = $i === 0 ? 'class="active"' : '';
?>
<li <?php echo $active; ?>><a href="<?php echo $link['link']['url']; ?>"><?php echo $link['link']['title']; ?></a></li>
<?php $i++; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</ul>
</section>
<?php endif; ?>
<?php
if( have_rows('flexible_content') ):
while ( have_rows('flexible_content') ) : the_row();
get_template_part( 'templates/modules/' . get_row_layout() . '', 'none' );
endwhile;
endif;
while ( have_posts() ) :
the_post();
?>
<?php the_content(); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- .flex-content -->
<?php get_footer('flex-content'); ?>