Metiers_du_patrimoine_theme/single-artisans.php
Nonimart 6fe1f0ff14
All checks were successful
continuous-integration/drone/push Build is passing
FEATURE Removing back to the results
2025-09-01 14:26:27 +02:00

255 lines
9.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
$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
$frontPageUrl = get_home_url();
$frontPageTitle = get_the_title(get_option('page_on_front'));
$searchPageId = 43;
$currentLang = apply_filters('wpml_current_language', null);
$searchPageId = apply_filters('wpml_object_id', $searchPageId, 'page', TRUE, $currentLang);
$searchPageTitle = get_the_title($searchPageId);
$searchPageUrl = get_post_permalink($searchPageId);
do_action('wpml_switch_language', 'fr');
$pageIcon = get_field('page_icon', $searchPageId) ?? null;
do_action('wpml_switch_language', $currentLang);
?>
<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/artisans/heading-box--artisan", null, array(
"pageIcon" => $pageIcon,
"title" => $currentPage->post_title,
"description" => __("En savoir plus sur cette entreprise", "metiers-patrimoine-theme"),
));
?>
<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
$artisans_id_fr = apply_filters('wpml_object_id', $post->ID, 'artisans', TRUE, 'fr');
$args = array(
'post_type' => 'chantiers',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'artisan',
'value' => $post->ID,
'compare' => '='
)
)
);
$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 while ($chantiers->have_posts()) : $chantiers->the_post(); ?>
<?php
$current_lang = apply_filters('wpml_current_language', null);
$current_chantier_ID = get_the_ID();
$chantier_description = get_field('description', $current_chantier_ID);
$date = get_field('date', $current_chantier_ID);
$localisation = get_field('localisation', $current_chantier_ID) ?? null;
$city = $localisation['city'] ? translate_city_name($localisation['city'], $current_lang) : null;
$current_id = get_the_ID();
//########## FORCE GET_FIELD IN FR TO BE SURE WE HAVE SAME PICTURES BETWEEN FR AND NL ##########
$chantier_fr_id = apply_filters('wpml_object_id', $current_chantier_ID, 'chantiers', TRUE, 'fr');
$pictures = get_field('pictures', $current_chantier_ID);
$chantier_name = get_field('chantier_name', $current_chantier_ID);
?>
<div class="chantier">
<h4 class="chantier__title"><?php echo $chantier_name ?></h4>
<div class="chantier__infos">
<?php if ($city): ?>
<p class="chantier__city"><?php echo $city ?></p>
<?php endif; ?>
<?php if ($date): ?>
<time class="chantier__date"> <?php echo $date ?></time>
<?php endif; ?>
</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 endwhile; ?>
</section>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</div>
</div>
<?php
get_template_part('template-components/informative-message/informative-message', null, array(
"message" => __("Ces fiches reprennent les informations communiquées par l'entreprise. Les erreurs éventuelles n'engagent pas la responsabilité de Homegrade.", "metiers-patrimoine-theme")
));
?>
</p>
<div class="previous-next-posts previous-next-artisan">
<?php
$prevPost = get_previous_post();
$nextPost = get_next_post();
?>
<?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; ?>
<?php if ($nextPost) : ?>
<?php $nextPostcover = get_the_post_thumbnail_url($nextPost->ID, 'full'); ?>
<a class="previous-next-posts__next previous-next-artisan__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; ?>
</div>
<?php
get_template_part('template-components/conseil-patrimoine-redirector', null, array());
?>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer();