updating component to make it more flexible

This commit is contained in:
Antoine M 2023-11-27 13:05:39 +01:00
parent 3feeba10b3
commit 05a4178ae0
2 changed files with 32 additions and 34 deletions

View File

@ -80,9 +80,27 @@ if (!function_exists('build_share_urls')) {
<?php
$blocks = parse_blocks($post->post_content);
$chapterBlockIndex = build_chapter_index($blocks);
$queryArgs = array(
'post_type' => 'brochures',
'posts_per_page' => 1,
'tax_query' => array(
array(
'taxonomy' => 'thematiques',
'field' => 'term_id',
'terms' => $currentThematique->term_id
)
)
);
$relatedBrochuresPosts = get_posts($queryArgs);
$relatedBrochure = get_field('brochure_pdf', $relatedBrochuresPosts[0]->ID) ?? null;
?>
<?php get_template_part('template-components/post-conseils/chapter-header', null, array(
'postID' => get_the_ID(),
'title' => get_the_title(get_the_ID()),
'ctaUrl' => $relatedBrochure['url'],
'ctaTitle' => __("Télécharger la brochure ", "homegrade-theme__texte-fonctionnel"),
'hasInfoCapsule' => true,
)); ?>
<div class=" conseils_wrapper">
<aside class="chapter_index">

View File

@ -1,6 +1,7 @@
<?php
$thematique = get_the_terms($args['postID'], 'thematiques')[0] ?? null;
$thematique_generale = $thematique->parent ? get_term($thematique->parent, 'thematiques') : $thematique;
$thematique_generale_id_fr =
@ -11,25 +12,6 @@ $thematique_generale_id_fr =
$thematique_picture = get_field('taxonomy_pictures', "thematiques_" . $thematique_generale_id_fr)['illustration_s'] ?? null;
$lastUpdate = get_the_modified_date('', $args['postID']);
$queryArgs = 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($queryArgs);
$relatedBrochure = get_field('brochure_pdf', $relatedBrochuresPosts[0]->ID) ?? null;
?>
@ -38,26 +20,24 @@ $relatedBrochure = get_field('brochure_pdf', $relatedBrochuresPosts[0]->ID) ?? n
<p class="post-conseils-chapter-header__page-thematic-title"><?php echo __("Les conseillers Homegrade vous guident", "homegrade-theme__texte-fonctionnel") ?></p>
<h1 class="post-conseils-chapter-header__page-title"><?php echo get_the_title($args['postID']) ?></h1>
<h1 class="post-conseils-chapter-header__page-title"><?php echo $args['title'] ?></h1>
<?php if ($relatedBrochure) : ?>
<?php if ($args['ctaUrl']) : ?>
<a class="cta cta--primary cta--button" href="<?php echo $args['ctaUrl'] ?>" target="<?php echo $args['ctaTarget'] ?? "_blank" ?>">
<?php
// echo '<pre>';
// print_r($relatedBrochure);
// echo '</pre>';
?>
<a class="cta cta--primary cta--button" href="<?php echo $relatedBrochure['url'] ?>" target="_blank">
<?php
echo __("Télécharger la brochure ", "homegrade-theme__texte-fonctionnel")
echo $args['ctaTitle'];
?><span class="sr-only"><?php echo $relatedBrochure['title'] ?></span> </a>
<?php endif; ?>
<?php if ($args['hasInfoCapsule']) : ?>
<?php
get_template_part('template-components/post-infos-capsule', null, array(
"postID" => $args['postID'],
"modified" => $lastUpdate
));
?>
<?php endif ?>
</div>
<img class="post-conseils-chapter-header__page-thematic-cover " src="<?php echo $thematique_picture['url'] ?>" alt="">