homegrade_theme_production/template-components/archives/brochure-rows.php

38 lines
1.7 KiB
PHP

<?php
// NEEDS TO BE A QUERY POST OBJECT
$brochuresPosts = $args['brochuresPosts'];
?>
<?php if ($brochuresPosts->have_posts()) : while ($brochuresPosts->have_posts()) : $brochuresPosts->the_post(); ?>
<?php
$brochurePdf = get_field('brochure_pdf', get_the_id()) ?? null;
// RETURN IF NO PDF
if (!$brochurePdf) continue;
$brochureCover = $brochurePdf['ID'] ? get_field('brochure_cover_image', $brochurePdf['ID']) : null;
$brochureEdition = get_field('brochure_edition', get_the_id()) ?? null;
$thematique = get_the_terms(get_the_id(), 'thematiques')[0] ?? null;
$rootThematic = getMainThematique($thematique) ?? null;
?>
<li class="publications-grid__row">
<?php if ($brochureCover) : ?>
<img class="publications-grid__cover" src="<?php echo $brochureCover['sizes']['medium'] ?>" alt="" />
<?php endif; ?>
<h3 class="publications-grid__title"><?php echo $brochurePdf['title'] ?></h3>
<p class="publications-grid__thematique thematique-tag thematique-tag--<?php echo $rootThematic->slug ?>"><?php echo $rootThematic->name ?></p>
<?php if ($brochureEdition) : ?>
<p class="publications-grid__edition"><?php echo $brochureEdition ?></p>
<?php endif; ?>
<div class="publications-grid__button">
<a href="<?php echo $brochurePdf['url'] ?>" class=" cta cta--secondary cta--button" href="#" target="_blank"><?php echo __("Consulter le PDF", "homegrade-theme__texte-fonctionnel__publications-archive") ?></a>
</div>
</li>
<?php endwhile ?>
<?php endif; ?>
<?php if (!$brochuresPosts->have_posts()) : ?>
<p class="publications-grid__no-results filters-no-results"><?php echo __("Aucune brochure n'a été trouvée", "homegrade-theme__texte-fonctionnel__publications-archive") ?></p>
<?php endif ?>