forked from DukeLivingHistory/RLH-Site-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
152 lines (134 loc) · 4.67 KB
/
index.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
<?php
// get featured content
$feat_cont_type = get_field( 'home_type', 'options' );
$feat_cont_id = get_field( 'home_'.$feat_cont_type, 'options' );
if( $feat_cont_type === 'collection' ){
$feat_cont = new ContentNodeCollection( $feat_cont_id );
} else {
$feat_cont = new ContentNode( $feat_cont_id );
}
$curated_items = get_field( 'curated_home_content', 'options' );
if( $curated_items ){
foreach( $curated_items as $curated_item ){
if( $curated_item['type'] === 'collection' ){
$curated_by_id[] = $curated_item['curated_collection'];
$curated[] = new ContentNodeCollection( $curated_item['curated_collection'] );
} else {
$curated_by_id[] = $curated_item[ 'curated_'.$curated_item['type'] ];
$curated[] = new ContentNode( $curated_item[ 'curated_'.$curated_item['type'] ] );
}
}
} else {
$curated_by_id = [];
$curated = [];
}
$curated_count = count( $curated );
$total_results = 11;
//limit total results to number set above
if( $curated_count < $total_results ){
// get interviews/transcripts
$interviews_and_transcripts = get_posts( [
'post_type' => ['timeline', 'interview'],
'posts_per_page' => $total_results,
'exclude' => $curated_by_id,
'meta_query' => [
[
'key' => 'hide',
'compare' => '!=',
'value' => 1
]
]
] );
// normalize data
if( count( $interviews_and_transcripts ) ){
foreach( $interviews_and_transcripts as $piece ){
if( !in_array( $piece->ID, $curated_by_id ) ){
$pieces[] = new ContentNode( $piece->ID );
}
}
}
// get collections
$collections = get_terms( [
'taxonomy' => ['collection'],
'posts_per_page' => $total_results
] );
// normalize data
if( count( $collections ) ){
foreach( $collections as $piece ){
if( !in_array( $piece->term_id, $curated_by_id ) ){
$pieces[] = new ContentNodeCollection( $piece->term_id );
}
}
}
// sort by publish date
usort( $pieces, function( $b, $a ){
return strcmp( $a->date, $b->date );
} );
$pieces = array_merge( $curated, $pieces );
$pieces = array_slice( $pieces, 0, $total_results );
} else {
$pieces = $curated;
}
?>
<article class="homeFeat">
<header class="post-header">
<div class="post-type"><?= icon( $feat_cont->type, 'type' ); ?><?= ucfirst( $feat_cont->type ); ?></div>
</header>
<div class="homeFeat-inner">
<?php if( $feat_cont->type === 'collection' ){ ?>
<i class="post-meta-label">A collection of</i>
<dl class="post-meta">
<dt class="sr-only">Number of interviews:</dt>
<dd>
<?= icon( 'interview', 'type' ); ?>
<?= $feat_cont->interview_count; ?> interview<?= $feat_cont->interview_count > 1 ? 's' : ''; ?>
</dd>
<?php if($feat_cont->timeline_count): ?>
<dt class="sr-only">Number of timelines:</dt>
<dd>
<?= icon( 'timeline', 'type' ); ?>
<?= $feat_cont->timeline_count; ?> timeline<?= $feat_cont->timeline_count > 1 ? 's' : ''; ?>
</dd>
<?php endif; ?>
</dl>
<?php } ?>
<div class="post-image js-img" data-showcredit data-img="<?= $feat_cont->img; ?>">
<a href="<?= $feat_cont->link; ?>">
<?= wp_get_attachment_image( $feat_cont->img, 'feat_home' ); ?>
</a>
</div>
<h2 class="post-title"><?= $feat_cont->title; ?></h2>
<?php if( $feat_cont->excerpt ){ ?>
<p class="post-excerpt"><?= $feat_cont->excerpt; ?></p>
<?php } ?>
<a class="post-link" href="<?= $feat_cont->link; ?>">View The <?= ucfirst( $feat_cont->type ); ?></a>
</div>
</article>
<?php if( count($pieces) > 3 ){ ?>
<section class="postRoll postRoll--featured">
<?php for( $i=0; $i<3; $i++ ){ $pieces[$i]->html(); } ?>
</section>
<?php if( get_field('show_roll_home', 'option') ){ ?>
<section class="postRoll postRoll--home">
<?php for( $i=3; $i<count($pieces); $i++ ){ $pieces[$i]->html(); } ?>
</section>
<?php } ?>
<?php } ?>
<section class="siteDescription">
<h2><?= get_field( 'site_description_header', 'options' ); ?></h2>
<?= get_field( 'site_description', 'options' ); ?>
<?php $links = get_field( 'site_description_links', 'options' ); ?>
<?php if( $links ){ ?>
<ul class="siteDescription-links">
<?php foreach( $links as $link ){ ?>
<li class="siteDescription-link">
<a href="<?= get_the_permalink( $link['home_link'] ); ?>">
<?= get_the_title( $link['home_link'] ); ?>
<?= icon( 'right', 'link' ); ?>
</a>
</li>
<?php } ?>
</ul>
<?php } ?>
</section>
<?php get_template_part('templates/buckets'); ?>