FEATURE Introducing a dedicated fonds-archives card
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d28911e49e
commit
df7918475d
|
|
@ -29,7 +29,7 @@ $posts_query = new WP_Query($query_args);
|
|||
<ul class="post-grid__list">
|
||||
<?php if (isset($posts_query) && $posts_query->have_posts()) : ?>
|
||||
<?php while ($posts_query->have_posts()) : $posts_query->the_post(); ?>
|
||||
<?php get_template_part('template-parts/components/cards/post-card', null, array(
|
||||
<?php get_template_part('template-parts/post-types/fonds-archives/fonds-archives-card', null, array(
|
||||
'ID' => get_the_ID(),
|
||||
)); ?>
|
||||
<?php endwhile; ?>
|
||||
|
|
|
|||
134
template-parts/post-types/fonds-archives/fonds-archives-card.php
Normal file
134
template-parts/post-types/fonds-archives/fonds-archives-card.php
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
$ID = $args['ID'] ?? null;
|
||||
$current_post_type = $args['current_post_type'] ?? get_post_type();
|
||||
$title = get_the_title($ID);
|
||||
$showExcerpt = $args['show_excerpt'] ?? false;
|
||||
|
||||
$showTags = $args['showTags'] ?? true;
|
||||
|
||||
$excerpt = get_the_excerpt($ID);
|
||||
|
||||
$has_post_thumbnail = has_post_thumbnail($ID);
|
||||
$thumbnail_url = get_the_post_thumbnail_url($ID) ?? null;
|
||||
$has_thumbnail_overlay = $args['has_thumbnail_overlay'] ?? false;
|
||||
|
||||
$start_date = get_field('start_date', $ID) ?? null;
|
||||
$end_date = get_field('end_date', $ID) ?? null;
|
||||
|
||||
$authors = get_field('authors', $ID);
|
||||
$has_main_author = get_field('has_main_author', $ID);
|
||||
$main_author = get_field('main_author', $ID);
|
||||
$editors = get_field('editors', $ID);
|
||||
|
||||
$has_publication_direction = get_field('has_publication_direction', $ID);
|
||||
$publication_directors = get_field('publication_directors', $ID);
|
||||
|
||||
$numerotation = get_post_meta($ID, 'post_numerotation', true);
|
||||
$tags = get_the_terms($ID, 'etiquettes');
|
||||
|
||||
$description = get_field('description', $ID);
|
||||
$birth_death_date = get_field('birth_death_date', $ID);
|
||||
|
||||
$card_link = carhop_get_post_card_link_according_to_post_datas($ID, $args);
|
||||
$link = $card_link['link'];
|
||||
$target = $card_link['target'];
|
||||
$external_link_text = $card_link['text'];
|
||||
$has_valid_link = $card_link['has_valid_link'];
|
||||
$is_external = $card_link['is_external'];
|
||||
|
||||
$card_classes = 'card post-card post-card--' . sanitize_html_class((string) $current_post_type);
|
||||
$card_classes .= $has_post_thumbnail ? ' post-card--has-thumbnail' : '';
|
||||
$card_classes .= ! $has_valid_link ? ' post-card--no-link' : '';
|
||||
|
||||
?>
|
||||
|
||||
<?php if ($has_valid_link) : ?>
|
||||
<a class="<?php echo esc_attr(trim($card_classes)); ?>"
|
||||
href="<?php echo esc_url($link); ?>"
|
||||
target="<?php echo esc_attr($target); ?>"
|
||||
<?php echo $is_external ? ' rel="noopener noreferrer"' : ''; ?>>
|
||||
<?php else : ?>
|
||||
<div class="<?php echo esc_attr(trim($card_classes)); ?>">
|
||||
<?php endif; ?>
|
||||
<?php if ($has_post_thumbnail) : ?>
|
||||
<div class="post-card__thumbnail">
|
||||
<img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>">
|
||||
<?php if ($has_thumbnail_overlay) : ?>
|
||||
<div class="thumbnail-overlay"></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="card__inner">
|
||||
<?php get_template_part('template-parts/components/content-meta', null, array(
|
||||
'current_post_type' => $current_post_type,
|
||||
'current_post_id' => $ID
|
||||
)); ?>
|
||||
<div class="card__content">
|
||||
<h3 class="card__title"><?php echo $title; ?></h3>
|
||||
<?php if ($showExcerpt) : ?>
|
||||
<div class="card__excerpt"><?php echo $excerpt; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($birth_death_date) : ?>
|
||||
<div class="card__birth-death-date"><?php echo $birth_death_date; ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($description) : ?>
|
||||
<div class="card__description"><?php echo $description; ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="card__details">
|
||||
|
||||
<div class="post-card__details-text">
|
||||
<div class="date">
|
||||
<?php if ($start_date) : ?>
|
||||
<time datetime="<?php echo $start_date; ?>" class="card__details-date date"><?php echo $start_date; ?></time>
|
||||
<?php endif; ?>
|
||||
<?php if ($start_date && $end_date) : ?>
|
||||
<span class="card__details-date-separator"> — </span>
|
||||
<?php endif; ?>
|
||||
<?php if ($end_date) : ?>
|
||||
<time datetime="<?php echo $end_date; ?>" class="card__details-date date"><?php echo $end_date; ?></time>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($authors) : ?>
|
||||
<ul class="post-card__authors">
|
||||
<?php if ($has_main_author && $main_author) : ?>
|
||||
<li class="main-author"><?php echo $main_author->post_title; ?></li>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($authors as $author) : ?>
|
||||
<li class="author"><?php echo $author->post_title; ?></li>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ($has_publication_direction && $publication_directors) : ?>
|
||||
<?php foreach ($publication_directors as $publication_director) : ?>
|
||||
<li class="publication-director">Sous la direction de <?php echo $publication_director->post_title; ?></li>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($editors) : ?>
|
||||
<li class="editor"><?php echo $editors; ?></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($current_post_type === 'outils-pedagogiques' && has_post_thumbnail($ID)) : ?>
|
||||
<div class="card__thumbnail">
|
||||
<?php the_post_thumbnail('medium'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ($showTags && $tags) : ?>
|
||||
<ul class="tag-list">
|
||||
<?php foreach ($tags as $tag) : ?>
|
||||
<li class="tag-list__tag"><?php echo $tag->name; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ($has_valid_link) : ?>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
Loading…
Reference in New Issue
Block a user