carhop__carhop-theme__DEV/template-parts/components/cards/archive-presse-card.php
Antoine M af540c312e
All checks were successful
continuous-integration/drone/push Build is passing
FEATURE refactoring presse components to handle datas with the new post type dedicated archives presses
2026-03-17 14:59:24 +01:00

97 lines
3.6 KiB
PHP

<?php
$ID = $args['ID'] ?? null;
$current_post_type = 'archives-presse';
$title = get_the_title($ID);
$showExcerpt = $args['show_excerpt'] ?? false;
$excerpt = get_the_excerpt($ID);
$link = get_field('source_url', $ID) ?? "#";
$has_post_thumbnail = has_post_thumbnail($ID);
$thumbnail_url = get_the_post_thumbnail_url($ID) ?? null;
$year = get_field('year', $ID);
$authors = get_field('authors', $ID);
$editors = get_field('editors', $ID);
$numerotation = get_post_meta($ID, 'post_numerotation', true);
$tags = get_the_terms($ID, 'etiquettes');
$media_types = get_field('media_type', $ID);
$media_types_list = array(
'audio' => 'Audio',
'video' => 'Vidéo',
'photo' => 'Photo',
'image' => 'Image',
'article' => 'Article',
);
?>
<a class="post-card post-card--archives-presse <?php $has_post_thumbnail ? 'post-card--has-thumbnail' : ''; ?> card" href="<?php echo $link; ?> " target="_blank">
<?php if ($has_post_thumbnail) : ?>
<div class="post-card__thumbnail">
<img src="<?php echo $thumbnail_url; ?>" alt="<?php echo $title; ?>">
</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; ?>
</div>
<div class="card__details">
<div class="post-card__details-text">
<time datetime="<?php echo $year; ?>" class="card__details-date date"><?php echo $year; ?></time>
<?php if ($authors) : ?>
<ul class="post-card__authors">
<?php foreach ($authors as $author) : ?>
<li class="author"><?php echo $author->post_title; ?></li>
<?php endforeach; ?>
<?php foreach ($editors as $editor) : ?>
<li class="editor"><?php echo $editor->post_title; ?></li>
<?php endforeach; ?>
</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 ($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; ?>
<?php if ($media_types) : ?>
<ul class="media-type-list">
<?php foreach ($media_types as $media_type) : ?>
<?php
$amount = $media_type['amount'];
$media_type = $media_type['acf_fc_layout'];
write_log($media_type);
if (!$amount || !$media_type) continue;
?>
<li class="media-type media-type--<?php echo esc_attr($media_type); ?>"><?php echo $amount . ' ' . ($media_types_list[$media_type] ?? $media_type) . ($amount > 1 ? 's' : ''); ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
</a>