homegrade_theme_production/template-publications.php
2023-08-21 17:33:36 +02:00

167 lines
6.2 KiB
PHP

<?php /* Template Name: Publications | Archive */
get_header();
$current_page_id = get_queried_object_id();
?>
<div class="template-archives template-archives--publications">
<nav class="breadcrumbs_navigation" aria-label="breadcrumbs">
<ol>
<li><a href="<?php echo home_url() ?>">Home</a></li>
<li><a href="<?php echo get_post_type_archive_link('brochures') ?>" aria-current='location'>Publications</a></li>
</ol>
</nav>
<section class="archive-page-header">
<h1 class="archive-page-header__title"><?php echo __("Nos publications", "homegrade-theme__texte-fonctionnel__archive-publications") ?></h1>
<p class="archive-page-header__description"><?php echo __("Découvrez toutes nos publications et outils en ligne", "homegrade-theme__texte-fonctionnel__archive-publications") ?>
</p>
<?php get_search_form(); ?>
</section>
<?php
$highlightedBrochureRelatedPost = get_field('highlighted_brochure', $current_page_id) ?? null;
$highlightedBrochurePdf = get_field('brochure_pdf', $highlightedBrochureRelatedPost->ID) ?? null;
$highlightedBrochureCover = get_field('brochure_cover_image', $highlightedBrochurePdf['ID']) ?? null;
$highlightedBrochureComment = get_field('highlighted_brochure_comment', $current_page_id) ?? null;
?>
<?php if ($highlightedBrochurePdf) : ?>
<div class="highlighted-brochure">
<div class="highlighted-brochure__wrapper">
<div class="highlighted-brochure__infos">
<div class="highlighted-brochure__titling">
<div class="highlighted-brochure__titling__icon">
<img src="<?php echo get_template_directory_uri() . '/resources/img/graphic-assets/house-homegrade-icon.svg' ?>" alt="">
</div>
<h3 class="highlighted-brochure__titling__title">
<?php echo __("Sélection de nos conseillers", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?>
</h3>
</div>
<?php if ($highlightedBrochureComment) : ?>
<p class="highlighted-brochure__comment"><?php echo $highlightedBrochureComment ?></p>
<?php endif; ?>
<a class="cta cta--secondary cta--button" href="<?php echo $highlightedBrochurePdf['url'] ?>" target="_blank"><?php echo __("Consulter le PDF", "homegrade-theme__texte-fonctionnel__archive-publications") ?></a>
</div>
<?php if ($highlightedBrochureCover) : ?>
<img class="highlighted-brochure__cover" src='<?php echo $highlightedBrochureCover['sizes']['large'] ?>' />
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<section class="brochures-archives">
<div class="section_titling section_titling--left">
<h2 class="section_titling__title"><?php echo __("Nos Brochures thématiques", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></h2>
<p class="section_titling__subtitle">Curabitur eleifend neque eu erat lacinia tincidunt</p>
</div>
<?php
$args = array(
'post_type' => 'brochures',
'posts_per_page' => 1,
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'date',
'meta_key' => 'brochure_pdf',
'meta_value' => '',
'meta_compare' => '!=',
// ICI METAQUERY FOR LE PDF
);
$brochures = new WP_Query($args);
?>
<ul class="brochures-grid">
<?php if ($brochures->have_posts()) : while ($brochures->have_posts()) : $brochures->the_post(); ?>
<?php
get_template_part('template-components/archives/brochure-grid-row', null, array('ID' => get_the_ID()));
?>
<?php endwhile ?>
<?php endif; ?>
</ul>
<button id="load-more-brochures" class="cta cta--button cta--shadowed" target="_blank"><?php echo __("Consulter plus de brochures", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></button>
<?php wp_reset_postdata(); ?>
</section>
<section class="fiches-infos-archives">
<div class="section_titling section_titling--left">
<h2 class="section_titling__title"><?php echo __("Nos Fiches infos", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></h2>
<p class="section_titling__subtitle">Phasellus elit turpis, viverra id porta gravida</p>
</div>
<?php
$args = array(
'post_type' => 'fiches-infos',
'posts_per_page' => 1,
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'date',
'meta_key' => 'brochure_pdf',
'meta_value' => '',
'meta_compare' => '!=',
// ICI METAQUERY FOR LE PDF
);
$fiches_infos = new WP_Query($args);
?>
<ul class="publications-grid">
<?php if ($fiches_infos->have_posts()) : while ($fiches_infos->have_posts()) : $fiches_infos->the_post(); ?>
<?php
$ficheInfoPdf = get_field('brochure_pdf', get_the_ID());
// $ficheInfoCover = get_field('brochure_cover', get_the_ID());
$ficheInfoCover = get_field('brochure_cover_image', $ficheInfoPdf['ID']);
$ficheInfoEdition = get_field('brochure_edition', get_the_ID());
$thematique = get_the_terms(get_the_ID(), 'thematiques')[0];
$rootThematic = getParentThematique($thematique);
?>
<li class="publications-grid__row">
<p>missing the cover</p>
<?php if ($ficheInfoCover) : ?>
<img class="brochures-grid__cover" src="<?php echo $ficheInfoCover['sizes']['medium'] ?>" />
<?php endif; ?>
<h2 class="publications-grid__title"><?php echo $ficheInfoPdf['title'] ?></h2>
<p class="publications-grid__thematique"><?php echo $rootThematic->name ?></p>
<?php if ($ficheInfoEdition) : ?>
<p class="publications-grid__edition"><?php echo $ficheInfoEdition ?></p>
<?php endif; ?>
<div class="publications-grid__button">
<a href="<?php echo $brochurePdf['url'] ?>" class=" cta cta--secondary cta--button" href="#" target="_blank"><?php echo __("Consulter le pdf", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></a>
</div>
</li>
<?php endwhile ?>
<?php endif; ?>
</ul>
<button id="load-more-brochures" class="cta cta--button cta--shadowed" target="_blank"><?php echo __("Consulter plus de fiches infos", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></button>
<?php wp_reset_postdata(); ?>
</section>
</div>
<?php
get_footer();