63 lines
2.4 KiB
PHP
63 lines
2.4 KiB
PHP
<?php
|
|
// $attributes = get_block_attributes();
|
|
// echo '<pre>';
|
|
// print_r($block);
|
|
// echo '</pre>';
|
|
|
|
$thematique = get_the_terms(get_the_ID(), 'thematiques')[0] ?? null;
|
|
$thematique_generale = $thematique->parent ? get_term($thematique->parent, 'thematiques') : $thematique;
|
|
$thematique_picture = get_field('taxonomy_pictures', "thematiques_" . $thematique_generale->term_id)['illustration_s'];
|
|
|
|
$lastUpdate = get_the_modified_date('', get_the_ID());
|
|
|
|
$args = array(
|
|
// 'fields' => 'ids',
|
|
'post_type' => 'brochures',
|
|
'posts_per_page' => 1,
|
|
'tax_query' => array(
|
|
array(
|
|
'taxonomy' => 'thematiques',
|
|
'field' => 'term_id',
|
|
'terms' => $thematique->term_id
|
|
)
|
|
)
|
|
);
|
|
$relatedBrochuresPosts = get_posts($args);
|
|
$relatedBrochure = get_field('brochures', $relatedBrochuresPosts[0]->ID);
|
|
$hasBrochure = $relatedBrochure['file_fr']['url'] ? true : false;
|
|
|
|
// echo '<pre>';
|
|
// // print_r($relatedBrochures[0]);
|
|
// // print_r($relatedBrochure['file_fr']['url'] ? "yes" : "no");
|
|
// // print_r(getThematiqueFamilySlug("acoustique"));
|
|
// // print_r("salut");
|
|
// // print_r($thematique);
|
|
// // print_r($thematique_generale);
|
|
// // print_r($thematique_picture);
|
|
// echo '</pre>';
|
|
?>
|
|
|
|
<section class="chapter-header-block <?php echo "bg-" . getThematiqueFamilySlug($thematique_generale->slug) . "-light" ?>">
|
|
<div class="chapter-header-block__infos">
|
|
<?php if ($thematique->parent == 0) : ?>
|
|
|
|
<p class="chapter-header-block__page-thematic-title <?php echo "text-" . getThematiqueFamilySlug($thematique_generale->slug) ?>"><?php echo __("Les conseillers Homegrade vous guident", "homegrade-theme__bloks-texte-fonctionnel") ?></p>
|
|
<?php else : ?>
|
|
<p class="chapter-header-block__page-thematic-title <?php echo "text-" . getThematiqueFamilySlug($thematique_generale->slug) ?>"><?php echo $thematique_generale->name ?></p>
|
|
<?php endif; ?>
|
|
|
|
|
|
<h1 class="chapter-header-block__page-title"><?php echo get_the_title() ?></h1>
|
|
|
|
<?php if ($hasBrochure) : ?>
|
|
<a class="cta cta--primary cta--button" href="<?php echo $relatedBrochure['file_fr']['url'] ?>" target="_blank">Télécharger la brochure <?php echo $relatedBrochures[0]->post_title ?></a>
|
|
<?php endif; ?>
|
|
<?php if ($lastUpdate) : ?>
|
|
<time>Dernière mise à jour : <?php echo $lastUpdate ?></time>
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
</div>
|
|
<img class="chapter-header-block__page-thematic-cover " src="<?php echo $thematique_picture['url'] ?>" alt="">
|
|
</section>
|