$block) {
if ($block['blockName'] == 'homegrade-content-blocks/chapitrage-thematique') {
foreach ($block['innerBlocks'] as $key => $innerBlock) {
if (!$innerBlock['attrs']['chapterTitle']) continue;
$cleanedTitle = strtolower(preg_replace("/[^a-zA-Z]/", "", $innerBlock['attrs']['chapterTitle']));
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => '#' . $cleanedTitle,
'title' => $innerBlock['attrs']['chapterTitle'],
]);
}
}
if ($block['blockName'] == 'homegrade-content-blocks/questions-container') {
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => '#questions-container-' . $block['attrs']['relatedPostId'],
'title' => get_the_title($block['attrs']['relatedPostId']),
]);
}
if ($block['blockName'] == 'homegrade-content-blocks/vocabulaire-summary') {
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => "#vocabulaire-summary",
'title' => __("Vocabulaire", "homegrade-theme__texte-fonctionnel") . " " . get_the_terms(get_the_ID(), "thematiques")[0]->name,
]);
}
if ($block['blockName'] == 'homegrade-content-blocks/plus-loin') {
array_push($chapterBlockIndex, [
'block-type' => $block['blockName'],
'anchor' => "#aller-plus-loin",
'title' => __("Pour aller plus loin", "homegrade-blocks__texte-fonctionnel"),
]);
}
}
return $chapterBlockIndex;
}
}
?>
slug;
?>
">
post_content);
$chapterBlockIndex = build_chapter_index($blocks);
$queryArgs = array(
'post_type' => 'brochures',
'posts_per_page' => 1,
'status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'thematiques',
'field' => 'term_id',
'terms' => $currentThematique->term_id,
'include_children' => false,
)
)
);
$relatedBrochuresPosts = get_posts($queryArgs);
$relatedBrochure = get_field('brochure_pdf', $relatedBrochuresPosts[0]->ID) ?? null;
$hasManualDocument = get_field('manual_source_document') ?? null;
$manualSrcDocument = get_field('manual_document_link');
$relatedDocumentUrl = ($hasManualDocument && $manualSrcDocument && $manualSrcDocument['source_document']) ? $manualSrcDocument['source_document']['url'] : $relatedBrochure['url'] ?? null;
$relatedDocumentCtaTitle = ($hasManualDocument && $manualSrcDocument && $manualSrcDocument['button_title']) ? $manualSrcDocument['button_title'] : __("Télécharger la brochure ", "homegrade-theme__texte-fonctionnel");
get_template_part('template-components/post-conseils/chapter-header', null, array(
'postID' => get_the_ID(),
'subtitle' => __("Les conseillers Homegrade vous guident", "homegrade-theme__texte-fonctionnel"),
'title' => get_the_title(get_the_ID()),
'ctaUrl' => $relatedDocumentUrl,
'ctaTitle' => $relatedDocumentCtaTitle,
'hasInfoCapsule' => true,
)); ?>