homegrade_theme_production/template-publications.php

166 lines
6.2 KiB
PHP

<?php /* Template Name: Publications | Archive */
get_header();
?>
<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__publications-archive-brochures") ?></h1>
<p class="archive-page-header__description"> <?php echo __("Découvrez toutes nos publications et outils en ligne", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?>
</p>
<?php get_search_form(); ?>
</section>
<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);
$current_page_id = get_queried_object_id();
$highlightedBrochure = get_field('highlighted_brochure', $current_page_id) ?? null;
$highlightedBrochurePdf = get_field('highlighted_brochure', $current_page_id) ?? null;
$highlightedBrochureComment = get_field('highlighted_brochure_comment', $current_page_id) ?? null;
?>
<?php if ($highlightedBrochure) : ?>
<div class="highlighted_brochure">
<h3><?php echo __("Sélection de nos conseillers", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></h3>
<h3><?php echo $highlightedBrochure->post_title ?></h3>
<?php if ($highlightedBrochureComment) : ?>
<p><?php echo $highlightedBrochureComment ?></p>
<?php endif; ?>
</div>
<?php
echo '<pre>';
print_r($highlightedBrochure);
echo '</pre>';
?>
<?php endif; ?>
<ul class="brochures-grid">
<?php if ($brochures->have_posts()) : while ($brochures->have_posts()) : $brochures->the_post(); ?>
<?php
$brochureCover = get_field('brochure_cover', get_the_ID());
$brochurePdf = get_field('brochure_pdf', get_the_ID());
$brochureEdition = get_field('brochure_edition', get_the_ID());
$thematique = get_the_terms(get_the_ID(), 'thematiques')[0];
$rootThematic = getParentThematique($thematique);
?>
<li class="brochures-grid__row">
<?php if ($brochureCover) : ?>
<img class="brochures-grid__cover" src="<?php echo $brochureCover['sizes']['medium'] ?>" />
<?php endif; ?>
<h2 class="brochures-grid__title"><?php echo $brochurePdf['title'] ?></h2>
<p class="brochures-grid__thematique"><?php echo $rootThematic->name ?></p>
<?php if ($brochureEdition) : ?>
<p class="brochures-grid__edition"><?php echo $brochureEdition ?></p>
<?php endif; ?>
<div class="brochures-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 toutes les 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 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' => '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
);
$brochures = new WP_Query($args);
?>
<ul class="brochures-grid">
<?php if ($brochures->have_posts()) : while ($brochures->have_posts()) : $brochures->the_post(); ?>
<?php
$brochureCover = get_field('brochure_cover', get_the_ID());
$brochurePdf = get_field('brochure_pdf', get_the_ID());
$brochureEdition = get_field('brochure_edition', get_the_ID());
$thematique = get_the_terms(get_the_ID(), 'thematiques')[0];
$rootThematic = getParentThematique($thematique);
?>
<li class="brochures-grid__row">
<?php if ($brochureCover) : ?>
<img class="brochures-grid__cover" src="<?php echo $brochureCover['sizes']['medium'] ?>" />
<?php endif; ?>
<h2 class="brochures-grid__title"><?php echo $brochurePdf['title'] ?></h2>
<p class="brochures-grid__thematique"><?php echo $rootThematic->name ?></p>
<?php if ($brochureEdition) : ?>
<p class="brochures-grid__edition"><?php echo $brochureEdition ?></p>
<?php endif; ?>
<div class="brochures-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 toutes les brochures", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></button>
<?php wp_reset_postdata(); ?>
</section>
</div>
<?php
get_footer();