-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive-colloquium.php
133 lines (121 loc) · 5.01 KB
/
archive-colloquium.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
<?php
get_header();
// Set correct year query from current date when no query_var present
if (date('m') > 8) {
$yearquery = date('Y');
} else {
$yearquery = date('Y') - 1;
}
// Set season date variables
$seasonstart = date('Ymd') - 1;
// Set pretty season range
// Format 'YYYY–YY' unless turn of century, in which case 'YYYY–YYYY'
if (($yearquery % 100) == 99) {
$seasontitle = $yearquery . '–' . ($yearquery + 1);
} else {
$seasontitle = $yearquery . '–' . str_pad((($yearquery + 1) % 100), 2, '0', STR_PAD_LEFT);
}
// Alter main query for displaying concerts in the loop
query_posts(
array(
'numberposts' => -1,
'post_type' => 'concert',
'meta_key' => 'dtstart',
'orderby' => 'dtstart',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'dtstart',
'value' => $seasonstart,
'compare' => '>='
)
)
)
);
// Get upcoming colloquia
$colloquia = event_query(array(
'post_type' => 'colloquium',
'order' => 'ASC',
'after' => $seasonstart
));
// Get upcoming miscellaneous events
$miscevents = event_query(array(
'post_type' => 'miscevent',
'order' => 'ASC',
'after' => $seasonstart
));
// Display events header and navigation
?>
<article id="events" class="section--events p-section clearfix">
<header class="archive-header">
<h2>Events</h2>
</header>
<?php
// What to do if there are no upcoming events
if (! (have_posts() || $colloquia || $miscevents)) {
echo '<section class="entry"><p>It looks like there are no events planned at the moment. Please check back later.</p></section>';
}
// Display archived concerts for $yearquery season
if (have_posts()) : ?>
<section class="concerts <?php if (!$colloquia) {
echo 'solo';
} ?>">
<h3 class="sans-sc-h3">Upcoming Concerts</h3>
<ul>
<?php while (have_posts()) {
the_post();
echo component('concert_list_item', array( "id" => get_the_ID() ));
} ?>
</ul>
</section>
<?php endif;
// Display archived colloquia for $yearquery season
if ($colloquia) : ?>
<section class="colloquia <?php if (!have_posts()) {
echo 'solo';
} ?>">
<h3 class="sans-sc-h3">Upcoming Colloquia</h3>
<?= component('colloquium_list', array(
"colloquia" => $colloquia,
"show_map_link" => true
)) ?>
</section>
<?php endif;
// Display archived miscellaneous events for $yearquery season
if ($miscevents): ?>
<section class="miscevents">
<h3 class="sans-sc-h3">Other Events</h3>
<ul>
<?php foreach ($miscevents as $miscevent): ?>
<li class="vevent clearfix">
<h4 class="dtstart">
<?php
$dtstart = DateTime::createFromFormat('d/m/Y', get_field('dtstart', $miscevent->ID));
$dtend = DateTime::createFromFormat('d/m/Y', get_field('dtend', $miscevent->ID));
echo '<time class="value-title" datetime="' . $dtstart->format('Y-m-d\TH:i:sO') . '" title="' . $dtstart->format('Y-m-d\TH:i:sO') . '">';
if (get_field('dtend', $miscevent->ID)) :
if ($dtstart->format('n') == $dtend->format('n')) :
echo $dtstart->format('n/j') . '–' . $dtend->format('j');
else :
echo $dtstart->format('n/j') . '–' . $dtend->format('n/j');
endif; ?>
<?php else : ?>
<?php echo $dtstart->format('n/j'); ?>
<?php endif; ?>
</time>
</h4>
<span class="summary"><a href="<?php echo get_permalink($miscevent->ID) ?>" class="url"><?php echo get_the_title($miscevent->ID); ?></a></span>
</li>
<?php endforeach; ?>
</ul>
</section>
<?php endif; ?>
<footer class="more-events-link">
<?= component('button_link', array(
'href' => get_post_type_archive_link('concert') . $yearquery . '/',
'html' => '<p>See all events from this season »</p>'
)) ?>
</footer>
<?php echo '</article>';
get_footer();
?>