carousel.php
13.4 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<?php
/**
* Carousel Block Template.
*
* @param array $block The block settings and attributes.
* @param string $content The block inner HTML (empty).
* @param bool $is_preview True during AJAX preview.
* @param (int|string) $post_id The post ID this block is saved to.
*/
// Create id attribute allowing for custom "anchor" value.
$id = 'carousel-' . $block['id'];
if( !empty($block['anchor']) ) {
$id = $block['anchor'];
}
// Create class attribute allowing for custom "className" and "align" values.
$className = 'carousel';
if( !empty($block['className']) ) {
$className .= ' ' . $block['className'];
}
if( !empty($block['align']) ) {
$className .= ' align' . $block['align'];
}
if( $is_preview ) {
$className .= ' is-admin';
}
$carousel_style = get_field('carousel_style');
error_log($carousel_style );
?>
<div id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($className); ?> ">
<?php switch($carousel_style){
case 'count-up-infographic':
?>
<?php if( have_rows('count_up_infographic_items') ): ?>
<div class="count-info carousel-items <?php echo $size; ?>"><div class='swiper-wrapper'>
<?php while( the_repeater_field('count_up_infographic_items') ):
?>
<div class="swiper-slide">
<?php $count = get_sub_field('count');?>
<div class="count-up-infographic-block vertical">
<div class='row'>
<div class='column col-3 infographic'>
<img src="<?= the_sub_field('infographic');?>" alt="infographic" />
</div>
<div class='column col-9'>
<?php if(!empty($count)){ ?>
<div class='row'>
<span class="countup"><?= $count; ?></span>
</div>
<?php } ?>
<div class='row'>
<p><?= the_sub_field('text'); ?></p>
</div>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div></div>
<div class="swiper-button-prev" data-id="<?= $id ?>"></div>
<div class="swiper-button-next" data-id="<?= $id ?>"></div>
<?php else: ?>
<p>Please add some slides.</p>
<?php endif; ?>
<?php break;
case 'testimonials': ?>
<?php if( have_rows('testimonials_items') ): ?>
<div class="testimonials-carousel carousel-items <?php echo $size; ?>"><div class='swiper-wrapper'>
<?php while( the_repeater_field('testimonials_items') ):
?>
<div class="swiper-slide">
<div id="<?php echo esc_attr($id); ?>" class=" testimonials">
<?php $image = get_sub_field('image'); ?>
<div class="row">
<div class="col-lg-4 col-md-1" style=background-image:url(<?php echo $image['url'];?>); >
</div>
<div class="col-lg-8 col-md-1">
<div class="testimonial-text"><p><?php the_sub_field('text'); ?></p></div></div>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
<div class="swiper-pagination"></div>
<div class="swiper-button-prev" data-id="<?= $id ?>"></div>
<div class="swiper-button-next" data-id="<?= $id ?>"></div>
</div>
<?php else: ?>
<p>Please add some slides.</p>
<?php endif; ?>
<?php break;
case 'story': ?>
<?php if( have_rows('story_items') ): ?>
<div class="stories carousel-items <?php echo $size; ?>"><div class='swiper-wrapper'>
<?php while( the_repeater_field('story_items') ):
if(get_sub_field('story_post')){
$post = get_sub_field('story_post');
$image = get_the_post_thumbnail_url($post->ID, 'full');
$title = $post->post_title;
$excerpt = get_excerpt_by_id($post->ID, 25);
}
if( get_sub_field('image')){
$image = get_sub_field('image');
$image = $image['url'];
}
if( get_sub_field('title')){
$title = get_sub_field('title');
}
if( get_sub_field('excerpt')){
$excerpt = get_sub_field('excerpt');
}
?>
<div class="swiper-slide">
<div class="story">
<a tabindex="-1" href="<?php echo get_permalink( $post->ID); ?>">
<div class="row">
<div class="col story-image" style=background-image:url(<?php echo $image;?>); ></div>
</div>
<div class="row">
<div class="col story-content sameHeight">
<div class="stories-text"><h3><?php echo $title; ?></h3><p><?php echo $excerpt; ?></p></div>
</div>
<div class="more-link">readmore</div>
</div>
</a>
</div>
</div>
<?php endwhile; ?>
</div></div>
<div class="swiper-button-prev" data-id="<?= $id ?>"></div>
<div class="swiper-button-next" data-id="<?= $id ?>"></div>
<?php else: ?>
<p>Please add some slides.</p>
<?php endif; ?>
<?php break;
case 'download': ?>
<?php if( have_rows('download_items') ): ?>
<div class="download carousel-items <?php echo $size; ?>"><div class='swiper-wrapper'>
<?php while( the_repeater_field('download_items') ):
?>
<?php $file = get_sub_field('file'); ?>
<div class="swiper-slide">
<div id="<?php echo esc_attr($id); ?>" class="download">
<a tabindex="-1" href="<?php echo $file; ?>" download>
<?php $image = get_sub_field('image'); ?>
<div class="row">
<div class="col download-image" style=background-image:url(<?php echo $image['url'];?>); ></div>
</div>
<div class="row">
<div class="col download-bar">
<div class="download-text">
download
</div>
</div>
</div>
</a>
</div>
</div>
<?php endwhile; ?>
</div></div>
<div class="swiper-button-prev" data-id="<?= $id ?>"></div>
<div class="swiper-button-next" data-id="<?= $id ?>"></div>
<?php else: ?>
<p>Please add some slides.</p>
<?php endif; ?>
<?php break;
case 'staff-diaries': ?>
<?php if( have_rows('staff_diaries_items') ): ?>
<div class="staff carousel-items <?php echo $size; ?>"><div class='swiper-wrapper'>
<?php while( the_repeater_field('staff_diaries_items') ):
?>
<?php $image = get_sub_field('image'); ?>
<div class="swiper-slide">
<div class="staff-diaries">
<div class="row">
<div class="col staff-image" style=background-image:url(<?php echo $image['url'];?>); ></div>
</div>
<div class="row">
<div class="col staff-content">
<?php the_sub_field('text'); ?>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
</div> </div>
<div class="swiper-button-prev" data-id="<?= $id ?>"></div>
<div class="swiper-button-next" data-id="<?= $id ?>"></div>
<?php else: ?>
<p>Please add some slides.</p>
<?php endif; ?>
<?php break;
case 'book-club': ?>
<?php if( have_rows('book_club_items') ): ?>
<div class="books carousel-items <?php echo $size; ?>"><div class='swiper-wrapper'>
<?php while( the_repeater_field('book_club_items') ):
?>
<?php $image = get_sub_field('image'); ?>
<div class="swiper-slide">
<div class="book-club">
<a tabindex="-1" href=" <?php the_sub_field('divnk'); ?>" target="_blank">
<div class="row">
<div class="col book-image" style=background-image:url(<?php echo $image['url'];?>); ></div>
</div>
<div class="row">
<div class="col book-content">
<?php the_sub_field('text'); ?>
</div>
</div>
</a>
</div>
</div>
<?php endwhile; ?>
</div> </div>
<div class="swiper-button-prev" data-id="<?= $id ?>"></div>
<div class="swiper-button-next" data-id="<?= $id ?>"></div>
<?php else: ?>
<p>Please add some slides.</p>
<?php endif; ?>
<?php break;
default: ?>
<p>Please select style.</p>
<?php }; ?>
</div>