FEATURE Introducing nested reusable components to handle better content and archive page
This commit is contained in:
parent
ff8716adbb
commit
582b7cf775
87
template-parts/analyses-etudes/analyses-etudes-grid.php
Normal file
87
template-parts/analyses-etudes/analyses-etudes-grid.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
$analyses_etudes_posts = new WP_Query(array(
|
||||
'post_type' => 'analyses-etudes',
|
||||
'posts_per_page' => -1
|
||||
));
|
||||
$post_count = $analyses_etudes_posts->post_count;
|
||||
$authors = get_posts(array(
|
||||
'post_type' => 'auteurs',
|
||||
'posts_per_page' => -1
|
||||
));
|
||||
|
||||
$types = get_terms(array(
|
||||
'taxonomy' => 'type',
|
||||
'hide_empty' => true,
|
||||
));
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<section class="post-grid content-section">
|
||||
<h2 class="find-publication__title title-small">Trouver une publication</h2>
|
||||
<div class="content-section__inner">
|
||||
|
||||
<div class="post-grid__toolbar">
|
||||
|
||||
<div class="search-by">
|
||||
<p class="search-by__label">Filtrer par</p>
|
||||
<div class="search-by__buttons" data-filter="thematique">
|
||||
<button data-filter="thematique" aria-selected="true">Thématique</button>
|
||||
|
||||
<button data-filter="occurence" aria-selected="false">Mot clé</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="post-grid__toolbar-actions" data-post-type="revues">
|
||||
<div class="search-bar">
|
||||
<input type="text" placeholder="<?php _e('Rechercher par mot-clé', 'dynamiques'); ?>">
|
||||
</div>
|
||||
|
||||
|
||||
<select name="types">
|
||||
<option value=""><?php _e('Tous les types', 'carhop'); ?></option>
|
||||
<?php foreach ($types as $type) : ?>
|
||||
<option value="<?php echo $type->slug; ?>" <?php selected($type_slug, $type->slug); ?>>
|
||||
<?php echo $type->name; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<select name="auteurs">
|
||||
<option value=""><?php _e('Tous·tes les auteur·e·s', 'dynamiques'); ?></option>
|
||||
<?php foreach ($authors as $author) : ?>
|
||||
<option value="<?php echo $author->ID; ?>"><?php echo $author->post_title; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<h2 class="post-count">
|
||||
<span class="post-count__count">
|
||||
<?php echo $post_count; ?>
|
||||
</span>
|
||||
<span class="post-count__text">
|
||||
<?php _e('revues', 'dynamiques'); ?>
|
||||
</span>
|
||||
</h2>
|
||||
<select name="sort_by">
|
||||
<option value="date_desc" selected><?php _e('Numéros récents en premier', 'dynamiques'); ?></option>
|
||||
<option value="date_asc"><?php _e('Numéros anciens en premier', 'dynamiques'); ?></option>
|
||||
<option value="title_asc"><?php _e('Par ordre alphabétique', 'dynamiques'); ?></option>
|
||||
</select>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<ul class="post-grid__list">
|
||||
<?php if (isset($analyses_etudes_posts) && $analyses_etudes_posts->have_posts()) : ?>
|
||||
<?php while ($analyses_etudes_posts->have_posts()) : $analyses_etudes_posts->the_post(); ?>
|
||||
<?php get_template_part('template-parts/analyses-etudes/card-analyse-etude', null, array(
|
||||
'ID' => get_the_ID(),
|
||||
|
||||
)); ?>
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
15
template-parts/analyses-etudes/archives-header.php
Normal file
15
template-parts/analyses-etudes/archives-header.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php get_template_part('template-parts/page-header', null, array(
|
||||
'title' => 'Analyses et études',
|
||||
'subtitle' => 'Accédez à nos recherches et publications thématiques',
|
||||
'description' => 'Le CARHOP produit des analyses et des études ancrées dans l’histoire sociale, en lien étroit avec les réalités du monde du travail et des mouvements sociaux. Ces productions visent à éclairer l’actualité par une lecture historique, critique et accessible.',
|
||||
'cover' => array(
|
||||
'url' => get_stylesheet_directory_uri() . '/resources/img/covers/carhop-page-analyses-etudes-cover.svg',
|
||||
'alt' => 'Revues'
|
||||
),
|
||||
'has_overlap' => true,
|
||||
'background_style' => 'sliced',
|
||||
'cta' => array(
|
||||
'title' => __('Trouver une publication', 'carhop'),
|
||||
'url' => '#prochaines-publications',
|
||||
)
|
||||
));
|
||||
42
template-parts/analyses-etudes/card-analyse-etude.php
Normal file
42
template-parts/analyses-etudes/card-analyse-etude.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
$ID = $args['ID'] ?? null;
|
||||
$types_terms = get_the_terms($ID, 'type');
|
||||
$type = isset($types_terms[0]) ? $types_terms[0] : null;
|
||||
$title = get_the_title($ID);
|
||||
$excerpt = get_the_excerpt($ID);
|
||||
$link = get_the_permalink($ID);
|
||||
$image = get_the_post_thumbnail_url($ID);
|
||||
$date = get_the_date('F Y', $ID);
|
||||
$author = get_the_author_meta('display_name', get_the_author_meta('ID', $ID));
|
||||
$author_link = get_the_author_link($ID);
|
||||
$author_avatar = get_avatar_url(get_the_author_meta('ID', $ID));
|
||||
$numerotation = get_post_meta($ID, 'post_numerotation', true);
|
||||
?>
|
||||
|
||||
<div class="post-card post-card--analyses-etudes card">
|
||||
<?php if ($type) : ?>
|
||||
<div class="content-meta">
|
||||
<span class="content-meta__type content-meta__type--revue"><?php echo $type->name; ?></span>
|
||||
<p class="content-meta__revue-issue content-meta__revue-issue--green">
|
||||
<span class="revue-issue-number revue-meta__label sr-only">Numéro</span>
|
||||
<?php echo $numerotation; ?>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="card__inner">
|
||||
<div class="card__content">
|
||||
<h3 class="card__title"><?php echo $title; ?></h3>
|
||||
<div class="card__excerpt"><?php echo $excerpt; ?></div>
|
||||
</div>
|
||||
<div class="card__details">
|
||||
<p class="card__details-text"><?php echo $excerpt; ?></p>
|
||||
|
||||
<time datetime="<?php echo $date; ?>" class="card__details-date date"><?php echo $date; ?></time>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
58
template-parts/analyses-etudes/toolbar-analyses-etudes.php
Normal file
58
template-parts/analyses-etudes/toolbar-analyses-etudes.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div class="post-grid__toolbar post-toolbar toolbar-analyses-etudes">
|
||||
|
||||
<div class="search-by">
|
||||
<p class="search-by__label">Filtrer par</p>
|
||||
<div class="search-by__buttons" data-filter="thematique">
|
||||
<button data-filter="thematique" aria-selected="true">Thématique</button>
|
||||
<button data-filter="auteur" aria-selected="false">Auteur·e</button>
|
||||
<button data-filter="occurence" aria-selected="false">Mot clé</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="post-grid__toolbar-actions" data-post-type="articles">
|
||||
<div class="search-bar">
|
||||
<input type="text" placeholder="<?php _e('Rechercher par mot-clé', 'dynamiques'); ?>">
|
||||
</div>
|
||||
|
||||
|
||||
<select name="etiquettes">
|
||||
<option value=""><?php _e('Tous les tags', 'dynamiques'); ?></option>
|
||||
<?php foreach ($thematiques as $thematique) : ?>
|
||||
<option value="<?php echo $thematique->slug; ?>" <?php selected($etiquette_slug, $thematique->slug); ?>>
|
||||
<?php echo $thematique->name; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<select name="auteurs">
|
||||
<option value=""><?php _e('Tous·tes les auteur·e·s', 'dynamiques'); ?></option>
|
||||
<?php foreach ($authors as $author) : ?>
|
||||
<option value="<?php echo $author->ID; ?>"><?php echo $author->post_title; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
|
||||
</div>
|
||||
<h2 class="post-count">
|
||||
<span class="post-count__count">
|
||||
<?php echo $post_count; ?>
|
||||
</span>
|
||||
<span class="post-count__text">
|
||||
<?php _e('articles', 'dynamiques'); ?>
|
||||
</span>
|
||||
</h2>
|
||||
|
||||
<select name="sort_by">
|
||||
<option value="date_desc" selected><?php _e('Numéros récents en premier', 'dynamiques'); ?></option>
|
||||
<option value="date_asc"><?php _e('Numéros anciens en premier', 'dynamiques'); ?></option>
|
||||
<option value="title_asc"><?php _e('Par ordre alphabétique', 'dynamiques'); ?></option>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
42
template-parts/components/archive/latest-parutions.php
Normal file
42
template-parts/components/archive/latest-parutions.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
$post_amount = $args['post_amount'] ?? 1;
|
||||
$post_type = $args['post_type'] ?? null;
|
||||
if (!$post_type) return;
|
||||
|
||||
$posts_query = new WP_Query(array(
|
||||
'post_type' => $post_type,
|
||||
'posts_per_page' => $post_amount,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
|
||||
));
|
||||
$posts = $posts_query->posts;
|
||||
$current_post_type = $args['current_post_type'] ?? get_post_type();
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div class="latest-parutions">
|
||||
<?php if ($post_amount > 1) : ?>
|
||||
<h2 class="latest-parutions__title title-small">Dernières parutions</h2>
|
||||
<?php else : ?>
|
||||
<h2 class="latest-parutions__title title-small">Dernière parution</h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($posts as $post) : ?>
|
||||
|
||||
<div class="post-card post-card--analyses-etudes">
|
||||
<div class="latest-parution__item">
|
||||
|
||||
<?php get_template_part('template-parts/components/content-meta', null, array(
|
||||
'current_post_type' => $current_post_type,
|
||||
'current_post_id' => $post->ID
|
||||
)); ?>
|
||||
<a href="<?php echo get_the_permalink($post->ID); ?>">
|
||||
<?php echo get_the_post_thumbnail($post->ID, 'medium'); ?>
|
||||
<h3><?php echo get_the_title($post->ID); ?></h3>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
93
template-parts/components/archive/post-grid.php
Normal file
93
template-parts/components/archive/post-grid.php
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
$post_amount = $args['post_amount'] ?? -1;
|
||||
$grid_title = $args['grid_title'] ?? 'Trouver une publication';
|
||||
|
||||
$current_post_type = $args['current_post_type'] ?? get_post_type();
|
||||
$current_post_type_obj = get_post_type_object($current_post_type);
|
||||
|
||||
$posts_query = new WP_Query(array(
|
||||
'post_type' => $current_post_type,
|
||||
'posts_per_page' => $post_amount
|
||||
));
|
||||
$post_count = $posts_query->post_count;
|
||||
|
||||
$types = get_terms(array(
|
||||
'taxonomy' => 'type',
|
||||
'hide_empty' => true,
|
||||
));
|
||||
|
||||
// write_log($current_post_type_obj);
|
||||
|
||||
?>
|
||||
|
||||
<section class="post-grid content-section">
|
||||
<h2 class="find-publication__title title-small"><?php echo $grid_title; ?></h2>
|
||||
<div class="content-section__inner">
|
||||
|
||||
<div class="post-grid__toolbar">
|
||||
|
||||
<div class="search-by">
|
||||
<p class="search-by__label">Filtrer par</p>
|
||||
<div class="search-by__buttons" data-filter="thematique">
|
||||
<button data-filter="thematique" aria-selected="true">Thématique</button>
|
||||
<button data-filter="occurence" aria-selected="false">Mot clé</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="post-grid__toolbar-actions" data-post-type="revues">
|
||||
<div class="search-bar">
|
||||
<input type="text" placeholder="<?php _e('Rechercher par mot-clé', 'dynamiques'); ?>">
|
||||
</div>
|
||||
|
||||
<select name="types">
|
||||
<option value=""><?php _e('Tous les types', 'carhop'); ?></option>
|
||||
<?php foreach ($types as $type) : ?>
|
||||
<option value="<?php echo $type->slug; ?>" <?php selected($type_slug, $type->slug); ?>>
|
||||
<?php echo $type->name; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<select name="auteurs">
|
||||
<option value=""><?php _e('Tous·tes les auteur·e·s', 'dynamiques'); ?></option>
|
||||
<?php foreach ($authors as $author) : ?>
|
||||
<option value="<?php echo $author->ID; ?>"><?php echo $author->post_title; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<h2 class="post-count">
|
||||
<span class="post-count__count">
|
||||
<?php echo $post_count; ?>
|
||||
</span>
|
||||
<?php if ($post_amount > 1) : ?>
|
||||
<span class="post-count__text">
|
||||
<?php echo $current_post_type_obj->labels->name; ?>
|
||||
</span>
|
||||
<?php else : ?>
|
||||
<span class="post-count__text">
|
||||
<?php echo $current_post_type_obj->labels->singular_name; ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</h2>
|
||||
<select name="sort_by">
|
||||
<option value="date_desc" selected><?php _e('Numéros récents en premier', 'dynamiques'); ?></option>
|
||||
<option value="date_asc"><?php _e('Numéros anciens en premier', 'dynamiques'); ?></option>
|
||||
<option value="title_asc"><?php _e('Par ordre alphabétique', 'dynamiques'); ?></option>
|
||||
</select>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<ul class="post-grid__list">
|
||||
<?php if (isset($posts_query) && $posts_query->have_posts()) : ?>
|
||||
<?php while ($posts_query->have_posts()) : $posts_query->the_post(); ?>
|
||||
<?php get_template_part('template-parts/components/post-card', null, array(
|
||||
'ID' => get_the_ID(),
|
||||
)); ?>
|
||||
<?php endwhile; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
28
template-parts/components/content-meta.php
Normal file
28
template-parts/components/content-meta.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
$current_post_id = $args['current_post_id'] ?? get_the_ID();
|
||||
$current_post_type = $args['current_post_type'] ?? null;
|
||||
$type = null;
|
||||
$current_post_type_supports_type = is_object_in_taxonomy($current_post_type, 'type');
|
||||
|
||||
if ($current_post_type_supports_type) {
|
||||
$type = get_the_terms($current_post_id, taxonomy: 'type') ?? null;
|
||||
// $current_post_type === 'analyses-etudes' && is_array($type) && !empty($type) && isset($type[0]->name
|
||||
} else {
|
||||
$current_post_type_obj = get_post_type_object($current_post_type);
|
||||
$type = $current_post_type_obj->labels->singular_name;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div class="content-meta">
|
||||
<?php if ($type) : ?>
|
||||
<span class="content-meta__type content-meta__type--revue"><?php echo $type ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<p class="content-meta__revue-issue content-meta__revue-issue--green">
|
||||
<span class="revue-issue-number revue-meta__label sr-only">Numéro</span>
|
||||
28
|
||||
</p>
|
||||
</div>
|
||||
44
template-parts/components/post-card.php
Normal file
44
template-parts/components/post-card.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
$ID = $args['ID'] ?? null;
|
||||
$current_post_type = $args['current_post_type'] ?? get_post_type();
|
||||
$types_terms = get_the_terms($ID, 'type');
|
||||
$type = isset($types_terms[0]) ? $types_terms[0] : null;
|
||||
$title = get_the_title($ID);
|
||||
$excerpt = get_the_excerpt($ID);
|
||||
$link = get_the_permalink($ID);
|
||||
$image = get_the_post_thumbnail_url($ID);
|
||||
$date = get_the_date('F Y', $ID);
|
||||
|
||||
$authors = get_field('authors', $ID);
|
||||
|
||||
$numerotation = get_post_meta($ID, 'post_numerotation', true);
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<div class="post-card post-card--<?php echo $current_post_type; ?> card">
|
||||
<?php get_template_part('template-parts/components/content-meta', null, array(
|
||||
'current_post_type' => $current_post_type,
|
||||
'current_post_id' => $ID
|
||||
)); ?>
|
||||
<div class="card__inner">
|
||||
<div class="card__content">
|
||||
<h3 class="card__title"><?php echo $title; ?></h3>
|
||||
<div class="card__excerpt"><?php echo $excerpt; ?></div>
|
||||
</div>
|
||||
<div class="card__details">
|
||||
|
||||
<time datetime="<?php echo $date; ?>" class="card__details-date date"><?php echo $date; ?></time>
|
||||
|
||||
<?php if ($authors) : ?>
|
||||
<ul class="post-card__authors">
|
||||
<?php foreach ($authors as $author) : ?>
|
||||
<li class="author"><?php echo $author->post_title; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
7
template-parts/components/subscribe-infolettre.php
Normal file
7
template-parts/components/subscribe-infolettre.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
$block_content = '<!-- wp:carhop-blocks/subscribe-infolettre {"title":"Restez connectés à l’histoire sociale","className":"wp-block-carhop-blocks-subscribe-infolettre subscribe-infolettre"} -->
|
||||
<!-- wp:paragraph {"placeholder":"Description","className":"subscribe-infolettre__description"} -->
|
||||
<p class="subscribe-infolettre__description">Recevez les dernières actualités du CARHOP et la revue Dynamiques directement dans votre boîte mail. Abonnez-vous et surveillez votre boîte : un mail de confirmation vous attend ! </p>
|
||||
<!-- /wp:paragraph -->
|
||||
<!-- /wp:carhop-blocks/subscribe-infolettre -->';
|
||||
echo do_blocks($block_content);
|
||||
15
template-parts/expositions/archive-header.php
Normal file
15
template-parts/expositions/archive-header.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php get_template_part('template-parts/page-header', null, array(
|
||||
'title' => 'Expositions',
|
||||
'subtitle' => 'Découvrez nos expositions thématiques',
|
||||
'description' => 'Le CARHOP conçoit et diffuse des expositions ancrées dans l’histoire sociale, en lien étroit avec le monde du travail, les luttes collectives et les réalités contemporaines. Pensées comme des outils de transmission et de sensibilisation, elles rendent visibles des récits, des archives et des parcours souvent absents des discours dominants.',
|
||||
'cover' => array(
|
||||
'url' => get_stylesheet_directory_uri() . '/resources/img/covers/carhop-page-analyses-etudes-cover.svg',
|
||||
'alt' => 'Revues'
|
||||
),
|
||||
'has_overlap' => true,
|
||||
'background_style' => 'sliced',
|
||||
'cta' => array(
|
||||
'title' => __('Trouver une exposition', 'carhop'),
|
||||
'url' => '#prochaines-expositions',
|
||||
)
|
||||
));
|
||||
15
template-parts/outils-pedagogiques/archive-header.php
Normal file
15
template-parts/outils-pedagogiques/archive-header.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php get_template_part('template-parts/page-header', null, array(
|
||||
'title' => 'Outils pédagogiques',
|
||||
'subtitle' => 'Transmettre l’histoire sociale autrement',
|
||||
'description' => 'Le CARHOP développe des outils pédagogiques à partir de ses recherches, de ses archives et de ses expositions. Pensés pour les enseignant·es, formateur·rices, animateur·rices et publics variés, ces supports facilitent l’appropriation de l’histoire sociale et ouvrent le débat sur les enjeux d’hier et d’aujourd’hui.',
|
||||
'cover' => array(
|
||||
'url' => get_stylesheet_directory_uri() . '/resources/img/covers/carhop-page-analyses-etudes-cover.svg',
|
||||
'alt' => 'Revues'
|
||||
),
|
||||
'has_overlap' => true,
|
||||
'background_style' => 'sliced',
|
||||
'cta' => array(
|
||||
'title' => __('Trouver un outil pédagogique', 'carhop'),
|
||||
'url' => '#next-outils-pedagogiques',
|
||||
)
|
||||
));
|
||||
|
|
@ -6,9 +6,10 @@ $description = $args['description'];
|
|||
$cover = $args['cover'];
|
||||
$background_style = $args['background_style'] ?? 'normal';
|
||||
$cta = $args['cta'];
|
||||
$has_overlap = $args['has_overlap'] ?? false;
|
||||
?>
|
||||
|
||||
<section class="page-header content-section content-section--full-width page-header--<?php echo $background_style; ?>-background">
|
||||
<section class="page-header content-section content-section--full-width page-header--<?php echo $background_style; ?>-background <?php echo $has_overlap ? 'page-header--has-overlap' : ''; ?>">
|
||||
<div class="content-section__inner page-header__inner">
|
||||
<div class="page-header__content">
|
||||
<h1 class="page-header__title title-small "><?php echo $title; ?></h1>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user