updating menu renovateur footer

This commit is contained in:
Antoine M 2024-01-26 10:37:12 +01:00
parent 4ae03aaa9f
commit b77da901fe

View File

@ -5,10 +5,8 @@ $menu = wp_get_nav_menu_object($locations[$menu_name]);
$menuitems = wp_get_nav_menu_items($menu->term_id, array('order' => 'DESC'));
$logoID = get_theme_mod('custom_logo');
$logoSRC = wp_get_attachment_image_src($logoID, 'full');
?>
<div class="menu-renovateur menu-renovateur--footer">
<div id="menu-renovateur-navlist-container" class="menu-renovateur__navlist-container" closed>
@ -88,24 +86,81 @@ $logoSRC = wp_get_attachment_image_src($logoID, 'full');
<li class="submenu-item sub-menu__navlist__item">
<?php
// #### IF IS TAXONOMY SUB-ITEM
if ($item->type === "taxonomy") :
<?php // #### WHEN IS POST TYPE CONSEIL SUB ITEM
?>
$term = get_term_by('id', $item->object_id, 'thematiques');
$cover = get_field('taxonomy_pictures', "thematiques_" . $item->object_id);
<?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);
$thematiqueColorslug = getThematiqueFamilySlug($postThematique->slug);
?>
<?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 class="<?php echo $thematiqueColorslug ? "text-" . $thematiqueColorslug : "" ?>"><?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);
$thematiqueColorslug = getThematiqueFamilySlug($term->slug);
$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);
?>
<a href="<?php echo get_term_link($term) ?>">
<?php if ($taxonomyRelatedPost) : ?>
<a href="<?php echo get_permalink($taxonomyRelatedPost->ID) ?>">
<?php if ($cover && $cover['icon']) : ?>
<img class="sub-menu__navlist__thematique-icon" src="<?php echo $cover['icon']['url'] ?>" alt="">
<?php endif; ?>
<div class="details">
<h6><?php echo $title; ?></h6>
<p class="sub-menu__navlist__description"><?php echo $term->description ?></p>
<h6 class="<?php echo $thematiqueColorslug ? "text-" . $thematiqueColorslug : "" ?>"><?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) ?>">
<?php if ($cover) : ?>
<img class="sub-menu__navlist__thematique-icon" src="<?php echo $cover['icon']['url'] ?>" alt="">
<?php endif; ?>
<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; ?>
<!-- IF CLASSIC SUBMENU -->
<?php else : ?>
<a href="<?php echo $link; ?>">
<p class="title"><?php echo $title; ?></p>
<p class="excerpt"><?php echo get_the_excerpt($item->object_id) ?></p>
</a>
<a href="<?php echo $link; ?>" class="title"><?php echo $title; ?></a>
<?php endif; ?>
</li>