-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive-edusource.php
204 lines (186 loc) · 5.94 KB
/
archive-edusource.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
<?php
/* Template Name: EduSource Archive
*/
get_header();?>
<div class="grid-container">
<div class="grid-x grid-margin-x align-bottom">
<div class="cell medium-5">
<h1 class="page-title"><?php the_title(); ?> finden</h1>
<p><?php the_field('lernstoff_intro') ?></p>
</div>
<div class="medium-7 cell">
<div class="new-source callout margin-top-2">
<div class="card-section">
<h4>Neue Quelle Hinzufügen</h4>
<div class="grid-x align-justify align-middle">
<p class="cell small-12 medium-auto margin-bottom-0"> Es fehlt noch was?<br>Hier kannst du selber Quellen hinzufügen.</p>
<div class="cell small-12 medium-shrink">
<a class="button tiny margin-top-1" href="<?php echo get_page_link( 2703 ); ?>" target="_blank">Quelle hinzufügen</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<hr>
<?php
// args
$args_filter = array(
'posts_per_page' => -1,
'post_type' => 'edusource',
'post_status' => 'publish',
);
$filter_query = new WP_Query( $args_filter );
if ( $filter_query->have_posts() ) {
$fachgebiete = array();
$schulformen = array();
$roles = array();
$tags = array();
$categories = array();
$licenses = array();
while ( $filter_query->have_posts() ) {
$filter_query->the_post();
$fachgebiet = get_field( 'fachgebiet' );
$role = get_field( 'role' );
$schulform = get_field( 'schulform' );
$category = get_field( 'lernresourcentyp' );
$license = get_field( 'licence' );
$tag_field = get_field('tags');
if( $fachgebiet ){
foreach ($fachgebiet as $tag){
$fachgebiete[$tag['value']] = $tag['label'];
}
}
if( $schulform ){
foreach ($schulform as $tag){
$schulformen[$tag['value']] = $tag['label'];
}
}
if( $role ){
foreach ($role as $tag){
$roles[$tag['value']] = $tag['label'];
}
}
if( $tag_field ){
foreach ($tag_field as $tag){
$tags[$tag->term_id] = $tag->name;
}
}
if( $category ){
foreach ($category as $tag){
$categories[$tag['value']] = $tag['label'];
}
}
if( $license ){
foreach ($license as $tag){
$licenses[$tag['value']] = $tag['label'];
}
}
}
}
function getSelectOptions($fieldName, $fieldChoices){
$options = '';
$selected = '';
if( !empty( get_query_var( $fieldName ) ) ){
$selected = get_query_var( $fieldName );
}
asort($fieldChoices);
foreach ($fieldChoices as $value => $label){
$current = '';
if ($selected == $value){
$current = 'selected';
}
$options .= '<option value="'.$value.'" '.$current.' >'.$label.'</option>';
}
return $options;
}
?>
<div class="grid-container">
<div class="grid-x grid-margin-x">
<div class="cell medium-6">
<label> <strong>Suche</strong>
<input class="edu-filter edu-filter__search" data-filter="search" type="search" placeholder="Suchbegriff eingeben">
</label>
</div>
<div class="medium-12 cell">
<h4>Filter:</h4>
</div>
</div>
<div class="grid-x grid-margin-x align-middle margin-bottom-3">
<div class="cell small-12 medium-4">
<label> Fachbereiche
<select class="edu-filter edu-filter__select" data-filter="fields" data-placeholder="..."> <!-- field from JS -->
<?php echo getSelectOptions('fachgebiet', $fachgebiete); ?>
</select>
</label>
</div>
<div class="cell small-12 medium-4">
<label> Zielgruppe
<select class="edu-filter edu-filter__select" data-filter="roles" data-placeholder="...">
<?php echo getSelectOptions('role', $roles); ?>
</select>
</label>
</div>
<div class="cell small-12 medium-4">
<label> Lizenz
<select class="edu-filter edu-filter__select" data-filter="licenses" data-placeholder="...">
<?php echo getSelectOptions('licence', $licenses); ?>
</select>
</label>
</div>
<div class="cell small-12 medium-4">
<label> Schulform
<select class="edu-filter edu-filter__select" data-filter="schooltype" data-placeholder="...">
<?php echo getSelectOptions('schulform', $schulformen); ?>
</select>
</label>
</div>
<div class="cell small-12 medium-4">
<label>Art der Seite
<select class="edu-filter edu-filter__select" data-filter="sourcetype" data-placeholder="...">
<?php echo getSelectOptions('lernresourcentyp', $categories); ?>
</select>
</label>
</div>
<div class="cell small-12 medium-4">
<label>Schlagworte
<select class="edu-filter edu-filter__select" data-filter="tags" data-placeholder="...">
<?php echo getSelectOptions('tags', $tags); ?>
</select>
</label>
</div>
<?php /*
<div class="cell small-12 medium-12">
<button class="edu-filter__reset button clear no-space">Reset</button>
</div>
*/ ?>
</div>
<?php
?>
<div class="edu-list grid-x grid-margin-x small-up-1 medium-up-3 large-up-3 block-grid">
<?php
$posts = get_posts(array(
'post_type' => array('edusource'),
'numberposts' => -1,
));
//$posts = wp_ulike_get_most_liked_posts( -1, array( 'edusource' ), 'edusource', 'all', 'like' );
if($posts)
{
foreach($posts as $post)
{?>
<div class="edu-item cell"
data-fields="<?php echo get_field_values('fachgebiet'); ?>"
data-roles="<?php echo get_field_values('role'); ?>"
data-licenses="<?php echo get_field_values('licence'); ?>"
data-schooltype="<?php echo get_field_values('schulform'); ?>"
data-sourcetype="<?php echo get_field_values('lernresourcentyp'); ?>"
data-tags="<?php echo get_field_values('tags'); ?>">
<?php get_template_part('template-parts/edusource/edu-card') ?>
</div>
<?php }
}
?>
</div>
</div>
<?php get_footer(); ?>