-
Notifications
You must be signed in to change notification settings - Fork 0
/
films_template.php
220 lines (162 loc) · 5.47 KB
/
films_template.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
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
<?php
/**
* @package WordPress
* @subpackage CinemaSalem v1
*/
/*
Template Name: FILMS & SHOWTIMES template
*/
$debug = false; //set debug mode
date_default_timezone_set('America/New_York');
get_header(); ?>
<div class="content_full" id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="films_blurb">
<h4><?php the_title() ?></h4>
<?php the_content();?>
</div>
<?php add_wpmt_cs_header('now playing'); ?>
<?php
$backup = clone $post;
$header_ct = 1;
$i = 0;
$day_one = 'Thursday';
//if today is Friday, add a week to $day (except for today)
if( $day_one == date( 'l' ) ) { $day_one .='+7 days'; }
$args = array(
'post_type' => 'wpmt_film',
'posts_per_page' => '-1',
'meta_key' => 'wpmt_film_start',
'orderby' => 'meta_value',
'order' => 'ASC',
);
$my_query = new WP_Query( $args );
if ( $my_query->have_posts() ) {
while ( $my_query->have_posts() ) { $my_query->the_post();
$timestamp = strtotime( get_field( 'wpmt_film_start' ) );
if ( ! get_field( 'wpmt_film_hide' ) && get_field( 'wpmt_film_start' ) != false ) {
// displays the film
if ( $timestamp >= strtotime( $day_one ) && ! ( $timestamp >= strtotime( 'next ' . $day_one ) ) && $header_ct < 2 ) {
//add next week header
add_wpmt_cs_header('next week');
$header_ct = 2;
}
elseif ( $timestamp >= strtotime( 'next ' . $day_one ) && $header_ct < 3 ) {
//add coming soon header
add_wpmt_cs_header('coming soon');
$header_ct = 3;
}
wpmt_cs_display_film_listing();
$i++;
//if there's a row of 5, clear the row and reset
if( $i == 5 ) {
echo '<div class="clear"> </div>';
$i = 0;
}
}
} // endwhile
} // endif
$post = clone $backup;
?>
<?php endwhile; else: ?>
<p><strong>Your requested post cannot be found.</strong><br /></p>
<p><a href="<?php bloginfo('blog_url'); ?>">Return to the homepage</a></p>
<?php endif; ?>
<div id="clear" class="clear"> </div>
</div><!-- end #content -->
<?php get_footer(); ?>
<?php
function wpmt_cs_display_film_listing() { ?>
<div class="fs_film">
<div class="fs_poster">
<a href="<?php the_permalink(); ?>">
<?php
if ( get_field( 'wpmt_film_poster' ) ) {
echo wp_get_attachment_image(get_field('wpmt_film_poster'),
$size = 'wpmt_poster',
$icon = false,
$attr = array('alt' => get_the_title($post), 'title' => get_the_title($post), 'id' => 'poster')
);
}
else {
echo '<img src="http://placehold.it/134x193?text=Film+Poster" id="poster">';
}
?>
</a>
</div>
<div class="fs_title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
<div class="fs_rating">
<?php if ( get_field('wpmt_film_genre') ) { the_field('wpmt_film_genre'); echo '<br />'; } ?>
<?php if ( get_field('wpmt_film_rating') ) { the_field('wpmt_film_rating'); } ?>
<?php if ( get_field('wpmt_film_rating')
&& get_field('wpmt_film_duration') ) { echo " / "; } ?>
<?php if ( get_field('wpmt_film_duration') ) { the_field('wpmt_film_duration'); echo " mins"; } ?>
</div>
<?php //if ( get_field('wpmt_screen_id') == '4' || get_field('wpmt_film_format') == '3D Digital' ) : ?>
<div class="fs_sr_3d">
<?php //if ( get_field('wpmt_screen_id') == '4' ) { echo "Presented in our intimate 18-seat screening room"; } ?>
<?php if ( get_field('wpmt_film_format') == '3D Digital' ) { echo "Presented in Fabulous 3D!"; } ?>
</div>
<?php //endif ?>
<div class="fs_description">
<?php echo wp_trim_words( get_field( 'wpmt_film_synopsis'), 40, '...' ); ?>
<a href="<?php the_permalink(); ?>">[MORE]</a>
</div>
Buy Tickets
<div class="fs_showtimes">
<?php
global $post;
$backup = clone $post;
if ( wpmt_sessions_exist ( get_field( 'wpmt_film_id' ) ) ) {
wpmt_display_sessions ( get_field( 'wpmt_film_id' ), 2 );
$post = clone $backup;
echo '<br /><br /><a href="' . get_permalink() . '">[MORE]</a>';
}
else {
$post = clone $backup;
echo "No tickets available at this time";
}
?>
</div>
<div class="clear"> </div>
</div> <!-- end fs_film -->
<?php } //end wpmt_cs_display_film_listing
function add_wpmt_cs_header( $header ) {
if ( $header == 'now playing' ) {
?>
<h1 class="homeh1"><a name="nowplaying">Now Playing</a>
</h1> <!-- (through " . date("l, M jS", strtotime("next Thursday")) . ") -->
<div class="h1nav">
<div>jump to:</div>
<div>[<a href="#nextweek">Coming Next Week</a>]</div>
<div>[<a href="#comingsoon">Coming Soon</a>]</div>
</div>
<div class="clear"> </div>
<?php
}
elseif ( $header == 'next week' ) {
?>
<h1 class="homeh1"><a name="nextweek">Coming Next Week</a></h1> <!-- (through " . date("l, M jS", strtotime("next Thursday")) . ") -->
<div class="h1nav">
<div>jump to: </div>
<div>[<a href="#nowplaying">Now Playing</a>]</div>
<div>[<a href="#comingsoon">Coming Soon</a>]</div>
</div>
<div class="clear"> </div>
<?php
}
elseif ( $header == 'coming soon' ) {
?>
<h1 class="homeh1"><a name="comingsoon">Coming Soon</a></h1> <!-- (through " . date("l, M jS", strtotime("next Thursday")) . ") -->
<div class="h1nav">
<div>jump to: </div>
<div>[<a href="#nowplaying">Now Playing</a>]</div>
<div>[<a href="#nextweek">Coming Next Week</a>]</div>
</div>
<div class="clear"> </div>
<?php
}
}// end add_header
?>