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

resource filters green and yellow

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