homegrade_theme_production/template-publications.php

368 lines
14 KiB
PHP

<?php /* Template Name: Publications | Archive */
get_header();
$current_page_id = get_queried_object_id();
$pageIcon = get_field('page_icon', get_queried_object_id()) ?? null;
$posts_per_page = 5;
// #### BROCHURES QUERY
$args = array(
'post_type' => 'brochures',
'posts_per_page' => $posts_per_page,
// 'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'date',
'meta_key' => 'brochure_pdf',
'meta_value' => '',
'meta_compare' => '!=',
);
$brochuresPosts = new WP_Query($args);
// $sortedBrochuresPosts = sort_posts_per_thematiques_priority($brochuresPosts);
// $sortedBrochuresPosts->posts = array_slice($sortedBrochuresPosts->posts, 0, $posts_per_page);
// $sortedBrochuresPosts->found_posts = $posts_per_page;
// $sortedBrochuresPosts->posts_per_page = $posts_per_page;
// $sortedBrochuresPosts->query_vars['posts_per_page'] = $posts_per_page;
// $sortedBrochuresPosts->post_count = $posts_per_page;
// #### FICHES INFOS QUERY
$args = array(
'post_type' => 'fiches-infos',
'posts_per_page' => $posts_per_page,
'post_status' => 'publish',
'order' => 'DESC',
'orderby' => 'date',
'meta_key' => 'brochure_pdf',
'meta_value' => '',
'meta_compare' => '!=',
);
$fichesInfosPosts = new WP_Query($args);
// $sortedFichesInfosPosts = sort_posts_per_thematiques_priority($fichesInfosPosts);
// $sortedFichesInfosPosts->posts = array_slice($sortedBrochuresPosts->posts, 0, $posts_per_page);
// $sortedFichesInfosPosts->found_posts = $posts_per_page;
// $sortedFichesInfosPosts->posts_per_page = $posts_per_page;
// $sortedFichesInfosPosts->query_vars['posts_per_page'] = $posts_per_page;
// $sortedFichesInfosPosts->post_count = $posts_per_page;
// #### WEBINAIRES QUERY
$args = array(
'post_type' => 'videos-webinaires',
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'DESC',
'meta_key' => 'video_publication_date',
'orderby' => 'meta_value_num',
);
$videosWebinairesPosts = new WP_Query($args);
// #### VIDÉOS & WEBINAIRES QUERY
// $videosWebinairesDatas = get_field('videos_webinaires', $current_page_id)['videos_webinaires_datas'] ?? null;
$total_posts_found = $brochuresPosts->found_posts + $fichesInfosPosts->found_posts + $videosWebinairesPosts->found_posts;
// $total_posts_found = $sortedBrochuresPosts->found_posts + $fichesInfosPosts->found_posts + $videosWebinairesPosts->found_posts;
?>
<div class="template-archives template-archives--publications">
<?php /* ------------
BREADCRUMB
-----------------*/ ?>
<nav class=" breadcrumbs_navigation" aria-label="<?php echo __("Vous êtes ici", "homegrade-theme__texte-fonctionnel") ?>">
<ol>
<li>
<a href="<?php echo home_url() ?>" title="<?php echo __("Accueil", "homegrade-theme__texte-fonctionnel") ?>">
<img src="<?php echo get_template_directory_uri() . "/resources/img/pictogrammes/icon_house_dark.svg" ?>" alt="">
</a>
</li>
<li><a href="<?php echo get_post_type_archive_link('brochures') ?>" aria-current='location' aria-disabled="true">Publications</a></li>
</ol>
</nav>
<?php /* ---------
HEADING BOX
-----------------*/ ?>
<?php
$receivePrintedPublicationsDatas = get_field('section_share_publications', $current_page_id) ?? null;
get_template_part("template-components/heading-box", null, array(
"pageIcon" => $pageIcon,
"title" => get_the_title(get_queried_object_id()),
"description" => __("Découvrez toutes nos publications et outils en ligne", "homegrade-theme__texte-fonctionnel"),
"ctaSecondary" => array(
"title" => $receivePrintedPublicationsDatas['cta_title'] ?? null,
"url" => $receivePrintedPublicationsDatas['cta_document']['url'] ?? null,
"target" => "_blank",
"custom-class" => "paper-button",
),
));
?>
<?php /* -------
FILTERS
---------------*/ ?>
<div class="filters-toolbar filters-toolbar--archive-publications" active-publication-type="all">
<!-- RESULTS INDICATIONS -->
<div class="filters-toolbar__posts-results-indications">
<p class="filters-toolbar__posts-results-amount filter-disable" role="status">
<span class="results-amount">
<?php echo $total_posts_found ?>
</span>
<span class="results-text">
<?php echo __("résultat(s)", "homegrade-theme__texte-fonctionnel"); ?>
</span>
<span class="results-for">
<?php echo __("pour", "homegrade-theme__texte-fonctionnel") . " : "; ?>
</span>
<span class="results-filter-name">
<?php echo __("categorie", "homegrade-theme__texte-fonctionnel"); ?>
</span>
</p>
<button class="filters-toolbar__action-button--load-all" data-term-id="all" data-publication-type="all"><?php echo __("Afficher toutes les publications", "homegrade-theme_texte-fonctionnel") ?></button>
</div>
<!-- FILTERS (PUBLICATIONS & THEMATIQUES) -->
<div class="filters-toolbar__filters-container">
<!-- PUBLICATIONS TYPES FILTERS -->
<ul class="publication-type-filters-wrapper">
<li>
<button class="filters-toolbar__action-button filters-toolbar__action-button--active" data-term-id="all" data-publication-type="all"><?php echo __("Tous", "homegrade-theme_texte-fonctionnel") ?></button>
</li>
<li>
<button class="filters-toolbar__action-button" data-publication-type="brochures">
<img class="icon" src="<?php echo get_template_directory_uri() . '/resources/img/pictogrammes/pictogramme-brochures.svg' ?>" alt='' />
<?php echo __("Brochures thématiques", "homegrade-theme__texte-fonctionnel") ?>
</button>
</li>
<li>
<button class="filters-toolbar__action-button" data-publication-type="fiches-infos">
<img class="icon" src="<?php echo get_template_directory_uri() . '/resources/img/pictogrammes/pictogramme-fiches.svg' ?>" alt='' />
<?php echo __("Fiches Info", "homegrade-theme__texte-fonctionnel") ?>
</button>
</li>
<li>
<button class="filters-toolbar__action-button" data-publication-type="webinaires">
<img class="icon" src="<?php echo get_template_directory_uri() . '/resources/img/pictogrammes/pictogramme-videos.svg' ?>" alt='' />
<?php echo __("Vidéos & Webinaires", "homegrade-theme__texte-fonctionnel") ?>
</button>
</li>
</ul>
<!-- THEMATIQUES FILTERS -->
<div class="action-thematiques-filters-wrapper">
<?php
$thematiques = get_terms(array(
'taxonomy' => 'thematiques',
'hide_empty' => true,
'parent' => 0,
));
?>
<div class="filters-toolbar__action-thematiques-filters">
<button class="filter-by-thematiques-submenu-toggle" aria-expanded="false"><?php echo __("Filtrer par thématique", "homegrade-theme__texte-fonctionnel") ?></button>
<ul class="action-thematiques-filters-list" hidden aria-hidden>
<li>
<input class="filters-toolbar__action-thematiques-filter--show-all" type="checkbox" id="all" name="all" value="all" checked>
<label for="all"><?php echo __("Tous", "homegrade-theme__texte-fonctionnel") ?></label>
</li>
<?php foreach ($thematiques as $thematique) : ?>
<li>
<input class="filters-toolbar__action-thematiques-filter" type="checkbox" id="<?php echo $thematique->slug ?>" name="<?php echo $thematique->slug ?>" value="<?php echo $thematique->term_id ?>" data-title="<?php echo $thematique->name ?>">
<label for="<?php echo $thematique->slug ?>"><?php echo $thematique->name ?></label>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<!-- ACTIVE FILTERS VIEWER -->
<div class="filters-toolbar__active-filters-viewer">
<div class="active-filters-button-container">
</div>
<button class="filters-toolbar__action-button--reset-filter cta cta--button cta--outline" hidden><?php echo __("Réinitialiser le filtre ", "homegrade-theme__texte-fonctionnel") ?></button>
</div>
</div>
<?php /* ---------------
HIGHLIGHTED BROCHURE
-----------------------*/ ?>
<div id="highlighted-document" class="highlighted-publication">
<?php
$highlightedDocumentDatas = get_field('highlighted_document', $current_page_id) ?? null;
$documentThumbnail = get_field('brochure_cover_image', $highlightedDocumentDatas['document']['ID']);
?>
<?php if ($highlightedDocumentDatas) : ?>
<div class="highlighted-publication__infos">
<div class="highlighted-publication__titling">
<div class="highlighted-publication__titling__icon">
<img src="<?php echo get_template_directory_uri() . '/resources/img/graphic-assets/house-homegrade-icon.svg' ?>" alt="">
</div>
<h3 class="highlighted-publication__titling__title">
<?php echo $highlightedDocumentDatas['highlight_title'] ?>
</h3>
</div>
<?php if ($highlightedDocumentDatas['commentary']) : ?>
<div class="highlighted-publication__comment"><?php echo $highlightedDocumentDatas['commentary'] ?></div>
<?php endif; ?>
<?php if ($highlightedDocumentDatas['document']) : ?>
<a class="cta cta--secondary cta--button" href="<?php echo $highlightedDocumentDatas['document']['url'] ?>" target="_blank"><?php echo __("Consulter le PDF", "homegrade-theme__texte-fonctionnel__archive-publications") ?></a>
<?php endif; ?>
</div>
<img class="highlighted-publication__cover" src='<?php echo get_template_directory_uri() . '/resources/img/illustrations/homegrade_brochure-impression.svg' ?>' />
<?php endif; ?>
</div>
<?php /* ---------
BROCHURES
-----------------*/ ?>
<section class="brochures-archives">
<div class="section_titling section_titling--left">
<?php
$sectionBrochureDatas = get_field('section_brochure_datas', $current_page_id);
?>
<h2 class="section_titling__title"><?php echo $sectionBrochureDatas['title'] ?></h2>
<p class="section_titling__subtitle"><?php echo $sectionBrochureDatas['subtitle'] ?></p>
</div>
<!-- BROCHURES GRID -->
<ul id="brochures-rows" class="publications-grid">
<?php
get_template_part(
'template-components/archives/brochure-rows',
null,
array(
'brochuresPosts' => $brochuresPosts,
)
)
?>
</ul>
<!-- LOAD MORE -->
<button id="load-more-brochures" class="cta cta--button cta--outline cta--button cta--centered cta--load-more" data-publication-type="brochures"><?php echo __("Consulter plus de brochures", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></button>
<?php wp_reset_postdata(); ?>
<?php /* ---------
DISTRIBUEZ PUBLICATIONS
-----------------*/ ?>
<?php
$sharePublications = get_field('section_share_publications', $current_page_id);
?>
</section>
<?php /* -----------
FICHES INFOS
------------------*/ ?>
<section class="fiches-infos-archives">
<div class="section_titling section_titling--left">
<?php
$sectionFichesInfosDatas = get_field('section_fiches_infos_datas', $current_page_id);
?>
<h2 class="section_titling__title"><?php echo $sectionFichesInfosDatas['title'] ?></h2>
<p class="section_titling__subtitle"><?php echo $sectionFichesInfosDatas['subtitle'] ?></p>
</div>
<ul id="fiche-infos-rows" class="publications-grid">
<?php
get_template_part(
'template-components/archives/fiche-info-rows',
null,
array(
'fichesInfosPosts' => $fichesInfosPosts,
)
)
?>
</ul>
<button id="load-more-brochures" class="cta cta--button cta--outline cta--button cta--centered cta--load-more" data-publication-type="fiches-infos"><?php echo __("Consulter plus de fiches infos", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?></button>
<?php wp_reset_postdata(); ?>
</section>
<?php /* ---------------
VIDÉOS & WEBINAIRES
-----------------------*/ ?>
<section class="videos-webinaires-archives">
<div class="section_titling section_titling--left">
<?php
$sectionWebinairesDatas = get_field('section_webinaires_datas', $current_page_id);
?>
<h2 class="section_titling__title"><?php echo $sectionWebinairesDatas['title'] ?></h2>
<p class="section_titling__subtitle"><?php echo $sectionWebinairesDatas['subtitle'] ?></p>
</div>
<?php
$highlightedWebinaire = get_field('highlighted_webinaire', $current_page_id) ?? null;
$webinaireThumbnail = get_the_post_thumbnail_url($highlightedWebinaire->ID);
$webinaireEmbed = get_field('embed', $highlightedWebinaire->ID);
$highlightedWebinaireUrl = get_field('url', $highlightedWebinaire->ID);
?>
<!-- HIGHLIGHTED WEBINAIRE -->
<div class="highlighted-publication">
<?php if ($highlightedWebinaire) : ?>
<div class="highlighted-publication__infos">
<div class="highlighted-publication__titling">
<div class="highlighted-publication__titling__icon">
<img src="<?php echo get_template_directory_uri() . '/resources/img/graphic-assets/house-homegrade-icon.svg' ?>" alt="">
</div>
<h3 class="highlighted-publication__titling__title">
<?php echo __("Sélection de nos conseillers", "homegrade-theme__texte-fonctionnel__publications-archive-brochures") ?>
</h3>
</div>
<h4 class="highlighted-publication__titling__subtitle"><?php echo $highlightedWebinaire->post_title ?></h4>
<p class="highlighted-publication__comment"><?php echo get_the_excerpt($highlightedWebinaire->ID) ?></p>
<a class="cta cta--secondary cta--button" href="<?php echo $highlightedWebinaireUrl ?>" target="_blank"><?php echo __("Consulter la vidéo", "homegrade-theme__texte-fonctionnel__archive-publications") ?></a>
</div>
<?php if ($webinaireEmbed) : ?>
<?php echo $webinaireEmbed ?>
<?php endif; ?>
<?php endif; ?>
</div>
<ul id="webinaires-rows" class="publications-grid publications-grid--webinaires">
<?php
get_template_part(
'template-components/archives/webinaire-rows',
null,
array(
'videosWebinairesPosts' => $videosWebinairesPosts,
)
)
?>
</ul>
<!-- <button id="load-more-brochures" class="cta cta--button cta--outline cta--button cta--centered cta--load-more" 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();