refining links handling in menu renovateur to accept both taxonomy term or conseil page as input
This commit is contained in:
parent
4a8d8c7f7e
commit
5c1748482d
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -7,4 +7,4 @@ Makefile
|
||||||
init_script.sh
|
init_script.sh
|
||||||
/css
|
/css
|
||||||
/js
|
/js
|
||||||
./css
|
.env
|
||||||
|
|
@ -65,6 +65,10 @@ function getMainThematique($thematique)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Get automatic post used in BLOCK QUESTIONS FREQUENTES
|
// Get automatic post used in BLOCK QUESTIONS FREQUENTES
|
||||||
function get_automatic_post($post_type)
|
function get_automatic_post($post_type)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
.chapter_index {
|
.chapter_index {
|
||||||
@apply bg-gray
|
@apply bg-gray
|
||||||
|
w-full
|
||||||
lg:max-w-lg
|
lg:max-w-lg
|
||||||
p-12
|
p-12
|
||||||
h-fit
|
h-fit
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ function build_chapter_index($blocks)
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
<?php if (have_posts()) : ?>
|
<?php if (have_posts()) : ?>
|
||||||
<?php while (have_posts()) : the_post(); ?>
|
<?php while (have_posts()) : the_post(); ?>
|
||||||
<?php
|
<?php
|
||||||
|
|
@ -78,8 +77,8 @@ function build_chapter_index($blocks)
|
||||||
?>
|
?>
|
||||||
<?php get_template_part('template-components/post-conseils/chapter-header'); ?>
|
<?php get_template_part('template-components/post-conseils/chapter-header'); ?>
|
||||||
<div class=" conseils_wrapper">
|
<div class=" conseils_wrapper">
|
||||||
<?php if ($chapterBlockIndex) : ?>
|
<aside class="chapter_index">
|
||||||
<aside class="chapter_index">
|
<?php if ($chapterBlockIndex) : ?>
|
||||||
<div class="chapter_index__titling">
|
<div class="chapter_index__titling">
|
||||||
<div class="icon"></div>
|
<div class="icon"></div>
|
||||||
<h2 class="chapter_index__title">Dans ce conseil</h2>
|
<h2 class="chapter_index__title">Dans ce conseil</h2>
|
||||||
|
|
@ -90,8 +89,8 @@ function build_chapter_index($blocks)
|
||||||
<li class="chapter_index__link"><a href="<?php echo $chapter['anchor'] ?>"><?php echo $chapter['title'] ?></a></li>
|
<li class="chapter_index__link"><a href="<?php echo $chapter['anchor'] ?>"><?php echo $chapter['title'] ?></a></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
<?php endif; ?>
|
||||||
<?php endif; ?>
|
</aside>
|
||||||
|
|
||||||
<!-- CHAPTER INDEX -->
|
<!-- CHAPTER INDEX -->
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ $logoSRC = wp_get_attachment_image_src($logoID, 'full');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="menu-renovateur">
|
<div class="menu-renovateur">
|
||||||
|
|
||||||
<div class="website_logo">
|
<div class="website_logo">
|
||||||
|
|
@ -34,10 +36,10 @@ $logoSRC = wp_get_attachment_image_src($logoID, 'full');
|
||||||
|
|
||||||
|
|
||||||
foreach ($menuitems as $key => $item) :
|
foreach ($menuitems as $key => $item) :
|
||||||
// write_log("item");
|
|
||||||
// write_log($item);
|
|
||||||
$link = $item->url;
|
$link = $item->url;
|
||||||
$title = $item->title;
|
$title = $item->title;
|
||||||
|
// write_log("item");
|
||||||
|
// write_log($item);
|
||||||
// $pageIcon = get_field('page_icon', $item->ID);
|
// $pageIcon = get_field('page_icon', $item->ID);
|
||||||
|
|
||||||
// echo '<pre>';
|
// echo '<pre>';
|
||||||
|
|
@ -112,23 +114,71 @@ $logoSRC = wp_get_attachment_image_src($logoID, 'full');
|
||||||
|
|
||||||
<li class="submenu-item sub-menu__navlist__item">
|
<li class="submenu-item sub-menu__navlist__item">
|
||||||
|
|
||||||
<?php
|
<?php // #### WHEN IS POST TYPE CONSEIL SUB ITEM
|
||||||
// #### IF IS TAXONOMY SUB-ITEM
|
|
||||||
if ($item->type === "taxonomy") :
|
|
||||||
|
|
||||||
$term = get_term_by('id', $item->object_id, 'thematiques');
|
|
||||||
$cover = get_field('taxonomy_pictures', "thematiques_" . $item->object_id);
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<a href="<?php echo get_term_link($term) ?>">
|
|
||||||
<img class="sub-menu__navlist__thematique-icon" src="<?php echo $cover['icon']['url'] ?>" alt="">
|
|
||||||
<div class="details">
|
|
||||||
<h6><?php echo $title; ?></h6>
|
|
||||||
<p class="sub-menu__navlist__description"><?php echo $term->description ?></p>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
<?php else : ?>
|
|
||||||
|
|
||||||
|
<?php if ($item->type === "post_type" && $item->type_label === "Conseil") : ?>
|
||||||
|
<?php
|
||||||
|
$postThematique = get_the_terms($item->object_id, "thematiques")[0];
|
||||||
|
$postParentThematique = getParentThematique($postThematique);
|
||||||
|
$thematiqueCover = get_field('taxonomy_pictures', "thematiques_" . $postParentThematique->term_id);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($postThematique) : ?>
|
||||||
|
|
||||||
|
<a href="<?php echo $item->url ?>">
|
||||||
|
<img class="sub-menu__navlist__thematique-icon" src="<?php echo $thematiqueCover['icon']['url'] ?>" alt="">
|
||||||
|
<div class="details">
|
||||||
|
<h6><?php echo $postThematique->name ?></h6>
|
||||||
|
<p class="sub-menu__navlist__description"><?php echo $postParentThematique->description ?></p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php // WHEN THE SUB-LINK IS A TAXONOMY TERM
|
||||||
|
?>
|
||||||
|
<?php elseif ($item->type === "taxonomy") : ?>
|
||||||
|
<?php
|
||||||
|
$term = get_term($item->object_id, 'thematiques');
|
||||||
|
$mainTaxonomyParent = getMainThematique($term);
|
||||||
|
$args = array(
|
||||||
|
'post_type' => 'conseils',
|
||||||
|
'posts_per_page' => 1,
|
||||||
|
'tax_query' => array(
|
||||||
|
array(
|
||||||
|
'taxonomy' => 'thematiques',
|
||||||
|
'field' => 'slug',
|
||||||
|
'terms' => $mainTaxonomyParent->slug,
|
||||||
|
'include_children' => false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$taxonomyRelatedPost = get_posts($args)[0] ?? null;
|
||||||
|
$cover = get_field('taxonomy_pictures', "thematiques_" . $mainTaxonomyParent->term_id);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($taxonomyRelatedPost) : ?>
|
||||||
|
<a href="<?php echo get_permalink($taxonomyRelatedPost->ID) ?>">
|
||||||
|
<img class="sub-menu__navlist__thematique-icon" src="<?php echo $cover['icon']['url'] ?>" alt="">
|
||||||
|
<div class="details">
|
||||||
|
<h6><?php echo $title; ?></h6>
|
||||||
|
<p class="sub-menu__navlist__description"><?php echo $mainTaxonomyParent->description ?></p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<?php else : ?>
|
||||||
|
<a href="<?php echo get_permalink($taxonomyRelatedPost->ID) ?>">
|
||||||
|
<img class="sub-menu__navlist__thematique-icon" src="<?php echo $cover['icon']['url'] ?>" alt="">
|
||||||
|
<div class="details">
|
||||||
|
<h6><?php echo $title; ?></h6>
|
||||||
|
<p class="sub-menu__navlist__description"><?php echo $mainTaxonomyParent->description ?></p>
|
||||||
|
<p class="!text-red-500 text-xs uppercase">pas de page conseil liée à cette thématique</p>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php else : ?>
|
||||||
|
<p>`qsdqsd</p>
|
||||||
<a href="<?php echo $link; ?>" class="title"><?php echo $title; ?></a>
|
<a href="<?php echo $link; ?>" class="title"><?php echo $title; ?></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user