296 lines
11 KiB
PHP
296 lines
11 KiB
PHP
<?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"),
|
||
));
|
||
?>
|
||
|
||
<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 l’entreprise", "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);
|
||
// write_log($chantiers->posts);
|
||
?>
|
||
<?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);
|
||
|
||
|
||
if ($current_chantier_ID === 8917 || $current_chantier_ID === 2732) {
|
||
// write_log($current_chantier_ID);
|
||
// write_log($chantier_name);
|
||
// write_log($pictures);
|
||
}
|
||
|
||
|
||
// Si déjà en français, inutile de switcher
|
||
// if ($current_lang !== 'fr') {
|
||
// // LANGUAGE IS NL
|
||
// $chantier_name = get_field('chantier_name', $chantier_fr_id);
|
||
// // $pictures = get_field('pictures', $chantier_fr_id);
|
||
// if ($chantier_fr_id == 2732) {
|
||
|
||
// write_log($current_lang);
|
||
// write_log("on est en NL ON SWITCHE");
|
||
// do_action('wpml_switch_language', 'fr');
|
||
// write_log($chantier_fr_id);
|
||
// }
|
||
// do_action('wpml_switch_language', $current_lang); // Revenir à la langue d’origine
|
||
|
||
// } else {
|
||
// // LANGUAGE IS FR
|
||
|
||
// $pictures = get_field('pictures', $current_chantier_ID);
|
||
// $test = get_field_object('pictures', $chantier_fr_id);
|
||
// if ($chantier_fr_id == 2732) {
|
||
// write_log($test);
|
||
// write_log($chantier_name);
|
||
// // write_log($pictures);
|
||
// // write_log($pictures);
|
||
// write_log($chantier_fr_id);
|
||
// write_log(get_the_ID());
|
||
// // write_log($pictures);
|
||
// }
|
||
|
||
|
||
// // On est déjà en FR, on ne switch pas
|
||
// }
|
||
|
||
|
||
?>
|
||
<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; ?>
|
||
</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 ($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();
|