Commit 89c8bfec authored by Benthe Kuijpers's avatar Benthe Kuijpers
Browse files

resource filters green and yellow

parent 120da12f
......@@ -381,7 +381,7 @@
"elements": [
"featured_image"
],
"min": 2,
"min": "",
"max": 6,
"return_format": "id"
},
......@@ -440,5 +440,5 @@
"hide_on_screen": "",
"active": true,
"description": "",
"modified": 1615210957
"modified": 1615216753
}
\ No newline at end of file
......@@ -12,27 +12,19 @@ $post_type_obj = get_post_type_object( $post_type ); ?>
</div>
<?php
$filters = get_terms( array('taxonomy' => 'resource-types', 'hide_empty' => false ) );
$filters = get_terms( array('taxonomy' => 'resource-types', 'hide_empty' => true ) );
if (!empty($filters)) { ?>
<div class="archive__filters">
<span><?php _e('filter', 'makeitopen'); ?></span>
<div class="filter-button" data-filter="*"><?php _e('all', 'makeitopen'); ?></div>
<div class="filter-button filter-button--active" data-filter="*"><?php _e('all', 'makeitopen'); ?></div>
<?php
// Build filter array with slugs combined with colours
$filter_colours = array('#06C770', '#F2E1B6', '#B383FF', '#65C4EA', '#FF6C8F');
$filter_array = array();
foreach ($filters as $key=>$filter) {
$colour = $filter_colours[$key];
$filter_array[$key] = array($filter->name, $filter->slug, $colour);
}
// Loop through filters to make buttons
foreach ($filter_array as $filter) { ?>
<div class="filter-button" data-filter=".<?php echo $filter[1]; ?>" style="background:<?php echo $filter[2]; ?>">
<?php echo lcfirst($filter[0]); ?>
foreach ($filters as $filter) { ?>
<div class="filter-button" data-filter=".<?php echo $filter->slug; ?>">
<?php echo lcfirst($filter->name); ?>
</div>
<?php } ?>
</div>
......@@ -53,21 +45,18 @@ $post_type_obj = get_post_type_object( $post_type ); ?>
if( $query->have_posts() ) :
while( $query->have_posts() ) : $query->the_post();
$resource_post = get_post();
$resource_filters = get_the_terms($resource_post, 'resource-types' );
// Make (combined) filter class for isotope
$filterclass = '';
if (!empty($filters)) {
foreach ($filters as $filter) {
if (!empty($resource_filters)) {
foreach ($resource_filters as $filter) {
$filterclass .= ' ' . $filter->slug;
}
}
if ($post_type_obj->name === 'resources') {
$resource_post = get_post();
include(locate_template('template-parts/elements/resource-teaser.php'));
} elseif ($post_type_obj->name === 'events') {
$event_post = get_post();
include(locate_template('template-parts/elements/events-teaser.php'));
}
include(locate_template('template-parts/elements/resource-teaser.php'));
endwhile;
endif; ?>
......
......@@ -11,10 +11,11 @@
mix-blend-mode: multiply;
margin: 0 10px 0 0;
box-shadow: none;
background: $green;
@include colourBg($bg-yellow, 0deg);
span {
background: rgba(black,0.1);
background: rgba(black,0.15);
padding: 0 5px;
margin: 0 -10px 0 5px;
}
......
.archive {
.page-header h1 {
@include colouredBar($green, $bg-yellow);
}
......@@ -17,7 +16,7 @@
.filter-button {
margin: 5px;
background: $lightblue;
background: $bg-yellow;
color: white;
font-weight: bold;
font-family: $font-header;
......@@ -26,11 +25,9 @@
@include colourBg($bg-yellow, 0deg);
cursor: pointer;
transition: all 0.25s ease-out;
}
&--active {
.filter-button:not(.filter-button--active) {
opacity: 0.4;
&--active {
background: $green;
}
}
}
......
<?php
$filters = get_the_terms($resource_post, 'resource-types' );
$type = get_field('type', $resource_post);
$url = ($type === 'url') ? get_field('url', $resource_post) : get_field('file', $resource_post); ?>
<div class="list__item <?php echo $filterclass; ?>">
<a href="<?php echo $url; ?>" target="_blank">
<?php
if (!empty($filters)) {
foreach($filters as $filter) {
$filter_key = array_search($filter->slug, array_column($filter_array, 1));
$colour = $filter_array[$filter_key][2];
echo '<span class="label" style="background:' . $colour . '">' . lcfirst($filter->name) . '<span>' . get_field('label', $resource_post) . '</span></span>';
if (!empty($resource_filters)) {
foreach($resource_filters as $filter) {
echo '<span class="label">' . lcfirst($filter->name) . '<span>' . get_field('label', $resource_post) . '</span></span>';
}
} ?>
<h2><?php echo get_the_title($resource_post); ?></h2>
......
......@@ -17,18 +17,20 @@
</div>
<div class="flex-grid">
<div class="events-wrapper">
<h3><?php _e('events', 'makeitopen'); ?></h3>
<?php
$event_items = get_sub_field('events');
foreach ($event_items as $event) {
$event_post = get_post($event);
include(locate_template('template-parts/elements/events-teaser.php'));
} ?>
<a href="<?php echo get_post_type_archive_link('events'); ?>" class="text-link"><?php _e('go to full agenda', 'makeitopen'); ?></a>
</div>
<?php
$event_items = get_sub_field('events');
if (!empty($event_items)) { ?>
<div class="events-wrapper">
<h3><?php _e('events', 'makeitopen'); ?></h3>
<?php
foreach ($event_items as $event) {
$event_post = get_post($event);
include(locate_template('template-parts/elements/events-teaser.php'));
} ?>
<a href="<?php echo get_post_type_archive_link('events'); ?>" class="text-link"><?php _e('go to full agenda', 'makeitopen'); ?></a>
</div>
<?php } ?>
<div class="resources-wrapper">
<h3><?php _e('resources', 'makeitopen'); ?></h3>
......@@ -37,23 +39,9 @@
$filters = get_terms( array(
'taxonomy' => 'resource-types',
'hide_empty' => false,
'hide_empty' => true,
) );
$filter_colours = array(
'#06C770',
'#F2E1B6',
'#B383FF',
'#65C4EA',
'#FF6C8F'
);
$filter_array = array();
foreach ($filters as $key=>$filter) {
$colour = $filter_colours[$key];
$filter_array[$key] = array($filter->name, $filter->slug, $colour);
}
foreach ($resource_items as $resource) {
$resource_post = get_post($resource);
include(locate_template('template-parts/elements/resource-teaser.php'));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment