<?php get_header();
$imgs = get_field('pdt_imgs');
$slider = false;
if(count($imgs)>1){
    $slider = true;
    $img_main = false;
    $img_main = $imgs[0];
}else{
    $slider = false;
    $img_main = $imgs[0];
}
?>

<div class="container-fluid">
    <div class="row">
        <div class="order-2 order-lg-1 col-12 col-lg-6 p-0 pdt_img">
        <?php if(!$slider){ ?>
            <img src="<?php echo $img_main['sizes']['large'];?>" alt="" class="img-fluid">
        <?php
        }else{
             echo '  <div class="slider_pdt">';
                foreach ($imgs as $img){
                    echo '<div class="item text-center">
                        <img class="img-fluid" alt="'.$img['alt'].'" src="'.$img['sizes']['large'].'">
                    </div>';
                }
            echo '</div>';
        }
        ?>
        </div>
        <div class="order-1 order-lg-2  col-12 col-lg-6">
            <div class="row">
                <div class="col-12 col-lg-8 offset-lg-1 product_info">
                    <?php if (function_exists('rank_math_the_breadcrumbs')) rank_math_the_breadcrumbs(); ?>
                    <h1 class="brown h1"><?php echo get_the_title();?></h1>
                    <div class="post_content">
                        <?php the_content();?>
                        <p class="mt-5 text-center text-lg-start">
                            <a href="<?php echo get_permalink(409);?>" class="arrow_link bg-beige white montserrat bold btn btn-lg">Je demande un devis</a>
                        </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="container-fluid py-5">
    <div class="container py-5">
        <div class="row">
            <div class="col-12">
                <div class="col-12 py-5 head_part">
                    <p class="suptitle"><strong>Nos produits</strong></p>
                    <h2 class="h3 beige sheila">Découvrir aussi...</h2>
                </div>
            </div>
        </div>
        <div class="row">
            <?php
            $args =array(
                'post_type' => 'produit',
                'post__not_in' => array( get_the_id()),
                'orderby'        => 'rand',
                'posts_per_page' => 2,
            );
            query_posts( $args );
            while ( have_posts() ) : the_post();
                        $pdt_imgs = get_field('pdt_imgs');
                        $img_data = $pdt_imgs[0];
                    ?>
                <div class="col-12 col-md-6 col-lg-4 offset-lg-1">
                    <a href="<?php echo get_permalink();?>" class="pdt_item d-block p-3">
                        <div class="pdt_item_img" style="background:url(<?php echo $img_data['sizes']['c_medium_false'];?>) no-repeat center center / cover">

                        </div>
                        <img src="<?php echo $img_data['sizes']['c_medium_false'];?>" alt="<?php echo get_the_title();?>" class="img-fluid d-none">
                        <h3 class="m-4 h3 brown bold underlined"><?php echo get_the_title();?></h3>
                    </a>
                </div>
            <?php

            endwhile;
            wp_reset_query();
            ?>
        </div>
    </div>
</div>

<?php get_footer(); ?>
