handling building chapters

This commit is contained in:
Antoine M 2024-07-01 15:43:05 +02:00
parent c57de6a332
commit e01315b972

View File

@ -19,8 +19,10 @@ $otherSteps = new WP_Query(array(
'post__not_in' => array(get_queried_object_id()) 'post__not_in' => array(get_queried_object_id())
)); ));
?> $blocks = parse_blocks($post->post_content);
$chapterBlockIndex = build_page_chapter_index($blocks); // see utilities.php
?>
@ -42,7 +44,6 @@ $otherSteps = new WP_Query(array(
</nav> </nav>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php <?php
$pageIcon = get_field('page_icon', $archiveParcours->ID); $pageIcon = get_field('page_icon', $archiveParcours->ID);
get_template_part("template-components/heading-box--parcours", null, array( get_template_part("template-components/heading-box--parcours", null, array(
@ -54,7 +55,24 @@ $otherSteps = new WP_Query(array(
?> ?>
<div class="parcours-content-wrapper conseils_wrapper"> <div class="parcours-content-wrapper conseils_wrapper">
<aside> <!-- CHAPTER INDEX -->
<aside class="chapter_index">
<?php if ($chapterBlockIndex) : ?>
<div class="chapter_index__titling">
<div class="icon">
<img src="<?php echo get_template_directory_uri() . '/resources/img/graphic-assets/icon-feather-menu.svg' ?>" alt="">
</div>
<h2 class="chapter_index__title"> <?php echo __("Dans ce conseil", "homegrade-theme__texte-fonctionnel") ?> </h2>
</div>
<ul class="chapter_index__list">
<div class="chapter_index__position-indicator"></div>
<?php foreach ($chapterBlockIndex as $chapter) : ?>
<li class="chapter_index__link"><a href="<?php echo $chapter['anchor'] ?>"><?php echo $chapter['title'] ?></a></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</aside>
<!-- <aside>
<div class="parcours-steps"> <div class="parcours-steps">
<div class="current-steps-index"> <div class="current-steps-index">
<?php if ($chapters->posts) : ?> <?php if ($chapters->posts) : ?>
@ -89,7 +107,7 @@ $otherSteps = new WP_Query(array(
</a> </a>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</aside> </aside> -->
<article class="container my-8 mx-auto entry-content single-editor-content"> <article class="container my-8 mx-auto entry-content single-editor-content">
@ -110,5 +128,3 @@ $otherSteps = new WP_Query(array(
</article> </article>
</div> </div>
<?php endwhile; ?>
<?php endif; ?>