Metiers_du_patrimoine_theme/single-artisans.php
Antoine M 99485faa0c
All checks were successful
continuous-integration/drone/push Build is passing
fixing translations namespace
2024-12-04 16:21:44 +01:00

236 lines
8.1 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
get_header();
?>
<?php
get_header();
$pageIcon = get_field('page_icon', get_queried_object_id()) ?? null;
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<nav class=" breadcrumbs_navigation" aria-label="<?php echo __("Vous êtes ici", "metiers-patrimoine-theme") ?>">
<?php
$currentPage = get_post(get_queried_object_id());
$networkHomeUrl = network_home_url();
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'template-repertoire-des-metiers.php'
));
//get page id with template Template Name: Repertoire des métiers
$frontPageUrl = get_home_url();
$frontPageTitle = get_the_title(get_option('page_on_front'));
$searchPageId = 43;
$searchPageTitle = get_the_title($searchPageId);
$searchPageUrl = get_post_permalink($searchPageId);
$pageIcon = get_field('page_icon', $searchPageId) ?? null;
?>
<ol>
<li>
<a href="<?php echo $networkHomeUrl ?>" title="<?php echo __("Accueil", "metiers-patrimoine-theme") ?>">
<img src="<?php echo get_template_directory_uri() . "/resources/img/pictogrammes/icon_house_dark.svg" ?>" alt="">
</a>
</li>
<li><a href="<?php echo $frontPageUrl ?>"><?php echo $frontPageTitle ?></a></li>
<li><a href="<?php echo $searchPageUrl ?>"><?php echo $searchPageTitle ?></a></li>
<?php if ($currentPage) : ?>
<li><a href="<?php echo get_post_permalink($currentPage->ID) ?>" aria-current="location" aria-disabled="true"><?php echo $currentPage->post_title ?></a></li>
<?php endif; ?>
</ol>
</nav>
<div class="homegrade-page-container metiers-patrimoine-page-container--single-artisans">
<?php /* --------
HEADING BOX
---------------*/ ?>
<?php
get_template_part("template-components/heading-box", null, array(
"pageIcon" => $pageIcon,
"title" => $currentPage->post_title,
"description" => __("En savoir plus sur nos artisans du patrimoine", "metiers-patrimoine-theme"),
));
?>
<a class="back-to-search" href="<?php echo $searchPageUrl ?>"><?php echo __("Retourner aux résultats de recherche", "metiers-patrimoine-theme") ?></a>
<div class="artisan_wrapper">
<aside class="artisan_info">
<?php
global $post;
$post_title = $post->post_title;
get_template_part(
'template-components/artisans/card-artisans-single',
null,
array(
'post_ID' => $post->ID,
'post_title' => $post_title,
)
);
get_template_part(
'template-components/artisans/card-taxonomies',
null,
array(
'post_ID' => $post->ID,
'post_title' => $post_title,
)
);
?>
</aside>
<div class="artisans-post">
<section class="artisans-post__section artisans-post__section--description">
<h2 class="artisans-post__section-title"><?php echo __("Activités de lentreprise", "metiers-patrimoine-theme") ?></h2>
<?php
$company_description = get_field('company_description');
$company_members = get_field('company_members');
?>
<p><?php echo $company_description ?></p>
</section>
<?php if ($company_members): ?>
<section class="artisans-post__section artisans-post__section--team ">
<h2 class="artisans-post__section-title"><?php echo __("L'équipe", "metiers-patrimoine-theme") ?></h2>
<?php
$company_description = get_field('company_description');
$company_members = get_field('company_members');
?>
<?php foreach ($company_members as $member): ?>
<?php
$member_gsm_number = $member['member_gsm_number'];
$formatted_member_gsm_number = preg_replace('/^(\+\d{2})(\d{3})(\d{2})(\d{2})(\d{2})$/', '$1 $2 $3 $4 $5', $member_gsm_number);
?>
<div class="artisan-member">
<img class="artisan-member__icon" src="<?php echo get_stylesheet_directory_uri() . '/resources/img/pictogrammes/Homegrade_repertoire-equipe.svg' ?>" alt="">
<div>
<h3 class="artisan-member__name"><?php echo $member['first_name'] . ' ' . $member['last_name'] ?></h3>
<?php if ($member_gsm_number): ?>
<a class="artisan-member__phone" href="tel:<?php echo $member_gsm_number ?>"><?php echo $formatted_member_gsm_number ?></a>
<?php endif; ?>
</div>
</div>
<p class="artisan-member__description"><?php echo $member['description'] ?></p>
<?php endforeach; ?>
</section>
<?php endif; ?>
<?php
$args = array(
'post_type' => 'chantiers',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'artisan',
'value' => $post->ID,
'compare' => 'LIKE'
)
)
);
$chantiers = new WP_Query($args);
?>
<?php if ($chantiers->posts): ?>
<section class="artisans-post__section artisans-post__section--chantiers">
<h2 class="artisans-post__section-title"> <?php echo __(" Chantiers réalisés ", "metiers-patrimoine-theme") ?>
</h2>
<?php foreach ($chantiers->posts as $chantier): ?>
<?php
$chantier_description = get_field('description', $chantier->ID);
$date = get_field('date', $chantier->ID);
// $city = get_field('city', $chantier->ID);
$city = get_field('city', $chantier->ID)['city'] ?? null;
// write_log($city);
$pictures = get_field('pictures', $chantier->ID);
?>
<div class="chantier">
<h4 class="chantier__title"><?php echo $chantier->post_title ?></h4>
<div class="chantier__infos">
<?php if ($city): ?>
<p class="chantier__city"><?php echo $city ?></p>
<?php endif; ?>
<time class="chantier__date"> <?php echo $date ?></time>
</div>
<p class="chantier__description"><?php echo $chantier_description ?></p>
<?php
// Rendre Un bloc acf/lightbox-gallery avec les photos du chantier
$block_content = '<!-- wp:acf/lightbox-gallery {"data":{"gallery":' . json_encode($pictures) . '}} /-->';
echo do_blocks($block_content);
?>
</div>
<?php endforeach; ?>
</section>
<?php endif; ?>
</div>
</div>
<div class="previous-next-posts previous-next-artisan">
<?php
$prevPost = get_previous_post();
$nextPost = get_next_post();
?>
<?php if ($nextPost) : ?>
<?php $nextPostcover = get_the_post_thumbnail_url($nextPost->ID, 'full'); ?>
<a class="previous-next-posts__next previous-next-artisans__next" href="<?php echo get_the_permalink($nextPost->ID) ?>">
<div class="previous-next-posts__link-content previous-next-artisan__link-content">
<p class="link-subtitle"><?php echo __("Entreprise suivante ", "metiers-patrimoine-theme") ?></p>
<p class="link-title"><?php echo $nextPost->post_title ?></p>
</div>
<?php if ($nextPostcover): ?>
<img class="previous-next-posts__post-thumbnail" src="<?php echo $nextPostcover ?>" alt="">
<?php endif; ?>
</a>
<?php endif; ?>
<?php if ($prevPost) : ?>
<?php $prevPostcover = get_the_post_thumbnail_url($prevPost->ID, 'full'); ?>
<a class="previous-next-posts__previous previous-next-artisan__previous" href="<?php echo get_the_permalink($prevPost->ID) ?>">
<?php if ($prevPostcover): ?>
<img class="previous-next-posts__post-thumbnail" src="<?php echo $prevPostcover ?>" alt="">
<?php endif; ?>
<div class="previous-next-posts__link-content previous-next-artisan__link-content">
<p class="link-subtitle"><?php echo __("Entreprise précédente ", "metiers-patrimoine-theme") ?></p>
<p class="link-title"><?php echo $prevPost->post_title ?></p>
</div>
</a>
<?php endif; ?>
</div>
<?php
get_template_part('template-components/conseil-patrimoine-redirector', null, array());
?>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer();