handling multi thematiques for fiches infos

This commit is contained in:
Antoine M 2024-02-26 15:54:37 +01:00
parent f631f95867
commit 1c9a7168eb
2 changed files with 22 additions and 3 deletions

View File

@ -20,6 +20,9 @@
&__thematique {
@apply col-span-5 md:col-span-2 text-center w-fit md:place-self-center;
}
&__thematiques-tags {
@apply col-span-5 md:col-span-2 md:place-self-center flex flex-col justify-center gap-4;
}
&__edition {
@apply col-span-6 md:col-span-2 md:text-center;
}

View File

@ -8,9 +8,13 @@ $fichesInfosPosts = $args['fichesInfosPosts'];
$ficheInfoPdf = get_field('brochure_pdf', get_the_ID()) ?? null;;
$ficheInfoEdition = get_field('brochure_edition', get_the_ID()) ?? null;
$thematique = get_the_terms(get_the_ID(), 'thematiques')[0] ?? null;
$rootThematic = getParentThematique($thematique) ?? null;
$thematiques = get_the_terms(get_the_ID(), 'thematiques');
$mainThematique = get_the_terms(get_the_ID(), 'thematiques')[0] ?? null;
$rootThematic = getParentThematique($mainThematique) ?? null;
$rootThematicIcon = get_field('taxonomy_pictures', "thematiques_" . $rootThematic->term_id)['icon'] ?? null;
?>
<li class="publications-grid__row">
@ -18,7 +22,19 @@ $fichesInfosPosts = $args['fichesInfosPosts'];
<img class="publications-grid__icon" src="<?php echo $rootThematicIcon['url'] ?>" />
<?php endif; ?>
<h2 class="publications-grid__title"><?php echo get_the_title() ?></h2>
<p class="publications-grid__thematique thematique-tag thematique-tag--<?php echo $rootThematic->slug ?>"><?php echo $rootThematic->name ?></p>
<div class="publications-grid__thematiques-tags">
<?php foreach ($thematiques as $thematique) : ?>
<?php
$rootThematic = getParentThematique($thematique) ?? null;
$rootThematicIcon = get_field('taxonomy_pictures', "thematiques_" . $rootThematic->term_id)['icon'] ?? null;
?>
<p class="publications-grid__thematique thematique-tag thematique-tag--<?php echo $rootThematic->slug ?>"><?php echo $rootThematic->name ?></p>
<?php endforeach; ?>
</div>
<?php if ($ficheInfoEdition) : ?>
<p class="publications-grid__edition"><?php echo $ficheInfoEdition ?></p>
<?php endif; ?>